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 Super cool mods and such v1.0.0
patchers/BepInEx.MonoMod.HookGenPatcher/BepInEx.MonoMod.HookGenPatcher.dll
Decompiled 2 years 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.InteropServices; using System.Security.Cryptography; using BepInEx.Configuration; using BepInEx.Logging; using Mono.Cecil; using MonoMod; using MonoMod.RuntimeDetour.HookGen; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Bepinex.Monomod.HookGenPatcher")] [assembly: AssemblyDescription("Runtime HookGen for BepInEx")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HarbingerOfMe")] [assembly: AssemblyProduct("Bepinex.Monomod.HookGenPatcher")] [assembly: AssemblyCopyright("HarbingerOfMe-2022")] [assembly: AssemblyTrademark("MIT")] [assembly: ComVisible(false)] [assembly: Guid("12032e45-9577-4195-8f4f-a729911b2f08")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: NeutralResourcesLanguage("en")] [assembly: AssemblyVersion("1.2.1.0")] namespace BepInEx.MonoMod.HookGenPatcher; public static class HookGenPatcher { internal static ManualLogSource Logger = Logger.CreateLogSource("HookGenPatcher"); private const string CONFIG_FILE_NAME = "HookGenPatcher.cfg"; private static readonly ConfigFile Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "HookGenPatcher.cfg"), true); private const char EntrySeparator = ','; private static readonly ConfigEntry<string> AssemblyNamesToHookGenPatch = Config.Bind<string>("General", "MMHOOKAssemblyNames", "Assembly-CSharp.dll", $"Assembly names to make mmhooks for, separate entries with : {','} "); private static readonly ConfigEntry<bool> preciseHash = Config.Bind<bool>("General", "Preciser filehashing", false, "Hash file using contents instead of size. Minor perfomance impact."); private static bool skipHashing => !preciseHash.Value; public static IEnumerable<string> TargetDLLs { get; } = new string[0]; public static void Initialize() { //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown string[] array = AssemblyNamesToHookGenPatch.Value.Split(new char[1] { ',' }); string text = Path.Combine(Paths.PluginPath, "MMHOOK"); string[] array2 = array; foreach (string text2 in array2) { string text3 = "MMHOOK_" + text2; string text4 = Path.Combine(Paths.ManagedPath, text2); string text5 = Path.Combine(text, text3); bool flag = true; string[] files = Directory.GetFiles(Paths.PluginPath, text3, SearchOption.AllDirectories); foreach (string text6 in files) { if (Path.GetFileName(text6).Equals(text3)) { text5 = text6; Logger.LogInfo((object)"Previous MMHOOK location found. Using that location to save instead."); flag = false; break; } } if (flag) { Directory.CreateDirectory(text); } FileInfo fileInfo = new FileInfo(text4); long length = fileInfo.Length; long num = 0L; if (File.Exists(text5)) { try { AssemblyDefinition val = AssemblyDefinition.ReadAssembly(text5); try { if (val.MainModule.GetType("BepHookGen.size" + length) != null) { if (skipHashing) { Logger.LogInfo((object)"Already ran for this version, reusing that file."); continue; } num = fileInfo.makeHash(); if (val.MainModule.GetType("BepHookGen.content" + num) != null) { Logger.LogInfo((object)"Already ran for this version, reusing that file."); continue; } } } finally { ((IDisposable)val)?.Dispose(); } } catch (BadImageFormatException) { Logger.LogWarning((object)("Failed to read " + Path.GetFileName(text5) + ", probably corrupted, remaking one.")); } } Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_PRIVATE", "1"); Environment.SetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW", "0"); MonoModder val2 = new MonoModder { InputPath = text4, OutputPath = text5, ReadingMode = (ReadingMode)2 }; try { IAssemblyResolver assemblyResolver = val2.AssemblyResolver; IAssemblyResolver obj = ((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null); if (obj != null) { ((BaseAssemblyResolver)obj).AddSearchDirectory(Paths.BepInExAssemblyDirectory); } val2.Read(); val2.MapDependencies(); if (File.Exists(text5)) { Logger.LogDebug((object)("Clearing " + text5)); File.Delete(text5); } Logger.LogInfo((object)"Starting HookGenerator"); HookGenerator val3 = new HookGenerator(val2, Path.GetFileName(text5)); ModuleDefinition outputModule = val3.OutputModule; try { val3.Generate(); outputModule.Types.Add(new TypeDefinition("BepHookGen", "size" + length, (TypeAttributes)1, outputModule.TypeSystem.Object)); if (!skipHashing) { outputModule.Types.Add(new TypeDefinition("BepHookGen", "content" + ((num == 0L) ? fileInfo.makeHash() : num), (TypeAttributes)1, outputModule.TypeSystem.Object)); } outputModule.Write(text5); } finally { ((IDisposable)outputModule)?.Dispose(); } Logger.LogInfo((object)"Done."); } finally { ((IDisposable)val2)?.Dispose(); } } } public static void Patch(AssemblyDefinition _) { } private static long makeHash(this FileInfo fileInfo) { FileStream inputStream = fileInfo.OpenRead(); byte[] value = null; using (MD5 mD = new MD5CryptoServiceProvider()) { value = mD.ComputeHash(inputStream); } long num = BitConverter.ToInt64(value, 0); if (num == 0L) { return 1L; } return num; } }
patchers/BepInEx.MonoMod.HookGenPatcher/MonoMod.dll
Decompiled 2 years ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Cecil.Mdb; using Mono.Cecil.Pdb; using Mono.Collections.Generic; using MonoMod.Cil; using MonoMod.InlineRT; using MonoMod.Utils; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("0x0ade")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright 2021 0x0ade")] [assembly: AssemblyDescription("General purpose .NET assembly modding \"basework\". This package contains the core IL patcher and relinker.")] [assembly: AssemblyFileVersion("21.8.5.1")] [assembly: AssemblyInformationalVersion("21.08.05.01")] [assembly: AssemblyProduct("MonoMod")] [assembly: AssemblyTitle("MonoMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("21.8.5.1")] [module: UnverifiableCode] internal static class MultiTargetShims { private static readonly object[] _NoArgs = new object[0]; public static TypeReference GetConstraintType(this TypeReference type) { return type; } } namespace MonoMod { [MonoMod__SafeToCopy__] public class MonoModAdded : Attribute { } [MonoMod__SafeToCopy__] public class MonoModConstructor : Attribute { } [MonoMod__SafeToCopy__] public class MonoModCustomAttributeAttribute : Attribute { public MonoModCustomAttributeAttribute(string h) { } } [MonoMod__SafeToCopy__] public class MonoModCustomMethodAttributeAttribute : Attribute { public MonoModCustomMethodAttributeAttribute(string h) { } } [MonoMod__SafeToCopy__] public class MonoModEnumReplace : Attribute { } [MonoMod__SafeToCopy__] public class MonoModForceCall : Attribute { } [MonoMod__SafeToCopy__] public class MonoModForceCallvirt : Attribute { } [MonoMod__SafeToCopy__] [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] [Obsolete("Use MonoModLinkFrom or RuntimeDetour / HookGen instead.")] public class MonoModHook : Attribute { public string FindableID; public Type Type; public MonoModHook(string findableID) { FindableID = findableID; } public MonoModHook(Type type) { Type = type; FindableID = type.FullName; } } [MonoMod__SafeToCopy__] public class MonoModIfFlag : Attribute { public MonoModIfFlag(string key) { } public MonoModIfFlag(string key, bool fallback) { } } [MonoMod__SafeToCopy__] public class MonoModIgnore : Attribute { } [MonoMod__SafeToCopy__] [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] public class MonoModLinkFrom : Attribute { public string FindableID; public Type Type; public MonoModLinkFrom(string findableID) { FindableID = findableID; } public MonoModLinkFrom(Type type) { Type = type; FindableID = type.FullName; } } [MonoMod__SafeToCopy__] public class MonoModLinkTo : Attribute { public MonoModLinkTo(string t) { } public MonoModLinkTo(Type t) { } public MonoModLinkTo(string t, string n) { } public MonoModLinkTo(Type t, string n) { } } [MonoMod__SafeToCopy__] public class MonoModNoNew : Attribute { } [MonoMod__SafeToCopy__] public class MonoModOnPlatform : Attribute { public MonoModOnPlatform(params Platform[] p) { } } [MonoMod__SafeToCopy__] public class MonoModOriginal : Attribute { } [MonoMod__SafeToCopy__] public class MonoModOriginalName : Attribute { public MonoModOriginalName(string n) { } } [MonoMod__SafeToCopy__] public class MonoModPatch : Attribute { public MonoModPatch(string name) { } } [MonoMod__SafeToCopy__] public class MonoModPublic : Attribute { } [MonoMod__SafeToCopy__] public class MonoModRemove : Attribute { } [MonoMod__SafeToCopy__] public class MonoModReplace : Attribute { } [MonoMod__SafeToCopy__] public class MonoModTargetModule : Attribute { public MonoModTargetModule(string name) { } } [MonoMod__SafeToCopy__] internal class MonoMod__SafeToCopy__ : Attribute { } public delegate bool MethodParser(MonoModder modder, MethodBody body, Instruction instr, ref int instri); public delegate void MethodRewriter(MonoModder modder, MethodDefinition method); public delegate void MethodBodyRewriter(MonoModder modder, MethodBody body, Instruction instr, int instri); public delegate ModuleDefinition MissingDependencyResolver(MonoModder modder, ModuleDefinition main, string name, string fullName); public delegate void PostProcessor(MonoModder modder); public delegate void ModReadEventHandler(MonoModder modder, ModuleDefinition mod); public class RelinkMapEntry { public string Type; public string FindableID; public RelinkMapEntry() { } public RelinkMapEntry(string type, string findableID) { Type = type; FindableID = findableID; } } public enum DebugSymbolFormat { Auto, MDB, PDB } public class MonoModder : IDisposable { public static readonly bool IsMono = (object)Type.GetType("Mono.Runtime") != null; public static readonly Version Version = typeof(MonoModder).Assembly.GetName().Version; public Dictionary<string, object> SharedData = new Dictionary<string, object>(); public Dictionary<string, object> RelinkMap = new Dictionary<string, object>(); public Dictionary<string, ModuleDefinition> RelinkModuleMap = new Dictionary<string, ModuleDefinition>(); public HashSet<string> SkipList = new HashSet<string>(EqualityComparer<string>.Default); public Dictionary<string, IMetadataTokenProvider> RelinkMapCache = new Dictionary<string, IMetadataTokenProvider>(); public Dictionary<string, TypeReference> RelinkModuleMapCache = new Dictionary<string, TypeReference>(); public Dictionary<string, OpCode> ForceCallMap = new Dictionary<string, OpCode>(); public ModReadEventHandler OnReadMod; public PostProcessor PostProcessors; public Dictionary<string, Action<object, object[]>> CustomAttributeHandlers = new Dictionary<string, Action<object, object[]>> { { "MonoMod.MonoModPublic", delegate { } } }; public Dictionary<string, Action<object, object[]>> CustomMethodAttributeHandlers = new Dictionary<string, Action<object, object[]>>(); public MissingDependencyResolver MissingDependencyResolver; public MethodParser MethodParser; public MethodRewriter MethodRewriter; public MethodBodyRewriter MethodBodyRewriter; public Stream Input; public string InputPath; public Stream Output; public string OutputPath; public List<string> DependencyDirs = new List<string>(); public ModuleDefinition Module; public Dictionary<ModuleDefinition, List<ModuleDefinition>> DependencyMap = new Dictionary<ModuleDefinition, List<ModuleDefinition>>(); public Dictionary<string, ModuleDefinition> DependencyCache = new Dictionary<string, ModuleDefinition>(); public Func<ICustomAttributeProvider, TypeReference, bool> ShouldCleanupAttrib; public bool LogVerboseEnabled; public bool CleanupEnabled; public bool PublicEverything; public List<ModuleReference> Mods = new List<ModuleReference>(); public bool Strict; public bool MissingDependencyThrow; public bool RemovePatchReferences; public bool PreventInline; public bool? UpgradeMSCORLIB; public ReadingMode ReadingMode = (ReadingMode)1; public DebugSymbolFormat DebugSymbolOutputFormat; public int CurrentRID; protected IAssemblyResolver _assemblyResolver; protected ReaderParameters _readerParameters; protected WriterParameters _writerParameters; public bool GACEnabled; private string[] _GACPathsNone = new string[0]; protected string[] _GACPaths; protected MethodDefinition _mmOriginalCtor; protected MethodDefinition _mmOriginalNameCtor; protected MethodDefinition _mmAddedCtor; protected MethodDefinition _mmPatchCtor; public virtual IAssemblyResolver AssemblyResolver { get { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown if (_assemblyResolver == null) { DefaultAssemblyResolver val = new DefaultAssemblyResolver(); foreach (string dependencyDir in DependencyDirs) { ((BaseAssemblyResolver)val).AddSearchDirectory(dependencyDir); } _assemblyResolver = (IAssemblyResolver)(object)val; } return _assemblyResolver; } set { _assemblyResolver = value; } } public virtual ReaderParameters ReaderParameters { get { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown if (_readerParameters == null) { _readerParameters = new ReaderParameters(ReadingMode) { AssemblyResolver = AssemblyResolver, ReadSymbols = true }; } return _readerParameters; } set { _readerParameters = value; } } public virtual WriterParameters WriterParameters { get { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0067: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if (_writerParameters == null) { bool flag = DebugSymbolOutputFormat == DebugSymbolFormat.PDB; bool flag2 = DebugSymbolOutputFormat == DebugSymbolFormat.MDB; if (DebugSymbolOutputFormat == DebugSymbolFormat.Auto) { if ((PlatformHelper.Current & 0x25) == 37) { flag = true; } else { flag2 = true; } } WriterParameters val = new WriterParameters { WriteSymbols = true }; object symbolWriterProvider; if (!flag) { if (!flag2) { symbolWriterProvider = null; } else { ISymbolWriterProvider val2 = (ISymbolWriterProvider)new MdbWriterProvider(); symbolWriterProvider = val2; } } else { ISymbolWriterProvider val2 = (ISymbolWriterProvider)new NativePdbWriterProvider(); symbolWriterProvider = val2; } val.SymbolWriterProvider = (ISymbolWriterProvider)symbolWriterProvider; _writerParameters = val; } return _writerParameters; } set { _writerParameters = value; } } public string[] GACPaths { get { if (!GACEnabled) { return _GACPathsNone; } if (_GACPaths != null) { return _GACPaths; } if (!IsMono) { string environmentVariable = Environment.GetEnvironmentVariable("windir"); if (string.IsNullOrEmpty(environmentVariable)) { return _GACPaths = _GACPathsNone; } environmentVariable = Path.Combine(environmentVariable, "Microsoft.NET"); environmentVariable = Path.Combine(environmentVariable, "assembly"); _GACPaths = new string[3] { Path.Combine(environmentVariable, "GAC_32"), Path.Combine(environmentVariable, "GAC_64"), Path.Combine(environmentVariable, "GAC_MSIL") }; } else { List<string> list = new List<string>(); string text = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName)), "gac"); if (Directory.Exists(text)) { list.Add(text); } string environmentVariable2 = Environment.GetEnvironmentVariable("MONO_GAC_PREFIX"); if (!string.IsNullOrEmpty(environmentVariable2)) { string[] array = environmentVariable2.Split(new char[1] { Path.PathSeparator }); foreach (string text2 in array) { if (!string.IsNullOrEmpty(text2)) { string path = text2; path = Path.Combine(path, "lib"); path = Path.Combine(path, "mono"); path = Path.Combine(path, "gac"); if (Directory.Exists(path) && !list.Contains(path)) { list.Add(path); } } } } _GACPaths = list.ToArray(); } return _GACPaths; } set { GACEnabled = true; _GACPaths = value; } } public MonoModder() { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) MethodParser = DefaultParser; MissingDependencyResolver = DefaultMissingDependencyResolver; PostProcessors = (PostProcessor)Delegate.Combine(PostProcessors, new PostProcessor(DefaultPostProcessor)); string environmentVariable = Environment.GetEnvironmentVariable("MONOMOD_DEPDIRS"); if (!string.IsNullOrEmpty(environmentVariable)) { foreach (string item in from dir in environmentVariable.Split(new char[1] { Path.PathSeparator }) select dir.Trim()) { IAssemblyResolver assemblyResolver = AssemblyResolver; IAssemblyResolver obj = ((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null); if (obj != null) { ((BaseAssemblyResolver)obj).AddSearchDirectory(item); } DependencyDirs.Add(item); } } LogVerboseEnabled = Environment.GetEnvironmentVariable("MONOMOD_LOG_VERBOSE") == "1"; CleanupEnabled = Environment.GetEnvironmentVariable("MONOMOD_CLEANUP") != "0"; PublicEverything = Environment.GetEnvironmentVariable("MONOMOD_PUBLIC_EVERYTHING") == "1"; PreventInline = Environment.GetEnvironmentVariable("MONOMOD_PREVENTINLINE") == "1"; Strict = Environment.GetEnvironmentVariable("MONOMOD_STRICT") == "1"; MissingDependencyThrow = Environment.GetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW") != "0"; RemovePatchReferences = Environment.GetEnvironmentVariable("MONOMOD_DEPENDENCY_REMOVE_PATCH") != "0"; string environmentVariable2 = Environment.GetEnvironmentVariable("MONOMOD_DEBUG_FORMAT"); if (environmentVariable2 != null) { environmentVariable2 = environmentVariable2.ToLowerInvariant(); if (environmentVariable2 == "pdb") { DebugSymbolOutputFormat = DebugSymbolFormat.PDB; } else if (environmentVariable2 == "mdb") { DebugSymbolOutputFormat = DebugSymbolFormat.MDB; } } string environmentVariable3 = Environment.GetEnvironmentVariable("MONOMOD_MSCORLIB_UPGRADE"); UpgradeMSCORLIB = (string.IsNullOrEmpty(environmentVariable3) ? null : new bool?(environmentVariable3 != "0")); GACEnabled = Environment.GetEnvironmentVariable("MONOMOD_GAC_ENABLED") != "0"; MonoModRulesManager.Register(this); } public virtual void ClearCaches(bool all = false, bool shareable = false, bool moduleSpecific = false) { if (all || shareable) { foreach (KeyValuePair<string, ModuleDefinition> item in DependencyCache) { item.Value.Dispose(); } DependencyCache.Clear(); } if (all || moduleSpecific) { RelinkMapCache.Clear(); RelinkModuleMapCache.Clear(); } } public virtual void Dispose() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) ClearCaches(all: true); ModuleDefinition module = Module; if (module != null) { module.Dispose(); } Module = null; ((IDisposable)AssemblyResolver)?.Dispose(); AssemblyResolver = null; foreach (ModuleDefinition mod in Mods) { if ((int)mod != 0) { mod.Dispose(); } } foreach (List<ModuleDefinition> value in DependencyMap.Values) { foreach (ModuleDefinition item in value) { if (item != null) { item.Dispose(); } } } DependencyMap.Clear(); Input?.Dispose(); Output?.Dispose(); } public virtual void Log(object value) { Log(value.ToString()); } public virtual void Log(string text) { Console.Write("[MonoMod] "); Console.WriteLine(text); } public virtual void LogVerbose(object value) { if (LogVerboseEnabled) { Log(value); } } public virtual void LogVerbose(string text) { if (LogVerboseEnabled) { Log(text); } } private static ModuleDefinition _ReadModule(Stream input, ReaderParameters args) { if (args.ReadSymbols) { try { return ModuleDefinition.ReadModule(input, args); } catch { args.ReadSymbols = false; input.Seek(0L, SeekOrigin.Begin); } } return ModuleDefinition.ReadModule(input, args); } private static ModuleDefinition _ReadModule(string input, ReaderParameters args) { if (args.ReadSymbols) { try { return ModuleDefinition.ReadModule(input, args); } catch { args.ReadSymbols = false; } } return ModuleDefinition.ReadModule(input, args); } public virtual void Read() { if (Module != null) { return; } if (Input != null) { Log("Reading input stream into module."); Module = _ReadModule(Input, GenReaderParameters(mainModule: true)); } else if (InputPath != null) { Log("Reading input file into module."); IAssemblyResolver assemblyResolver = AssemblyResolver; IAssemblyResolver obj = ((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null); if (obj != null) { ((BaseAssemblyResolver)obj).AddSearchDirectory(Path.GetDirectoryName(InputPath)); } DependencyDirs.Add(Path.GetDirectoryName(InputPath)); Module = _ReadModule(InputPath, GenReaderParameters(mainModule: true, InputPath)); } string environmentVariable = Environment.GetEnvironmentVariable("MONOMOD_MODS"); if (string.IsNullOrEmpty(environmentVariable)) { return; } foreach (string item in from path in environmentVariable.Split(new char[1] { Path.PathSeparator }) select path.Trim()) { ReadMod(item); } } public virtual void MapDependencies() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown foreach (ModuleDefinition mod in Mods) { ModuleDefinition main = mod; MapDependencies(main); } MapDependencies(Module); } public virtual void MapDependencies(ModuleDefinition main) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (DependencyMap.ContainsKey(main)) { return; } DependencyMap[main] = new List<ModuleDefinition>(); Enumerator<AssemblyNameReference> enumerator = main.AssemblyReferences.GetEnumerator(); try { while (enumerator.MoveNext()) { AssemblyNameReference current = enumerator.Current; MapDependency(main, current); } } finally { ((IDisposable)enumerator).Dispose(); } } public virtual void MapDependency(ModuleDefinition main, AssemblyNameReference depRef) { MapDependency(main, depRef.Name, depRef.FullName, depRef); } public virtual void MapDependency(ModuleDefinition main, string name, string fullName = null, AssemblyNameReference depRef = null) { if (!DependencyMap.TryGetValue(main, out var value)) { value = (DependencyMap[main] = new List<ModuleDefinition>()); } if (fullName != null && (DependencyCache.TryGetValue(fullName, out var value2) || DependencyCache.TryGetValue(fullName + " [RT:" + main.RuntimeVersion + "]", out value2))) { LogVerbose("[MapDependency] " + ((ModuleReference)main).Name + " -> " + ((ModuleReference)value2).Name + " ((" + fullName + "), (" + name + ")) from cache"); value.Add(value2); MapDependencies(value2); return; } if (DependencyCache.TryGetValue(name, out value2) || DependencyCache.TryGetValue(name + " [RT:" + main.RuntimeVersion + "]", out value2)) { LogVerbose("[MapDependency] " + ((ModuleReference)main).Name + " -> " + ((ModuleReference)value2).Name + " (" + name + ") from cache"); value.Add(value2); MapDependencies(value2); return; } string text = Path.GetExtension(name).ToLowerInvariant(); bool flag = text == "pdb" || text == "mdb"; string text2 = null; foreach (string dependencyDir in DependencyDirs) { text2 = Path.Combine(dependencyDir, name + ".dll"); if (!File.Exists(text2)) { text2 = Path.Combine(dependencyDir, name + ".exe"); } if (!File.Exists(text2) && !flag) { text2 = Path.Combine(dependencyDir, name); } if (File.Exists(text2)) { break; } text2 = null; } if (text2 == null && depRef != null) { try { AssemblyDefinition obj = AssemblyResolver.Resolve(depRef); value2 = ((obj != null) ? obj.MainModule : null); } catch { } if (value2 != null) { text2 = value2.FileName; } } if (text2 == null) { string[] gACPaths = GACPaths; for (int i = 0; i < gACPaths.Length; i++) { text2 = Path.Combine(gACPaths[i], name); if (Directory.Exists(text2)) { string[] directories = Directory.GetDirectories(text2); int num = 0; int num2 = 0; for (int j = 0; j < directories.Length; j++) { string text3 = directories[j]; if (text3.StartsWith(text2)) { text3 = text3.Substring(text2.Length + 1); } Match match = Regex.Match(text3, "\\d+"); if (match.Success) { int num3 = int.Parse(match.Value); if (num3 > num) { num = num3; num2 = j; } } } text2 = Path.Combine(directories[num2], name + ".dll"); break; } text2 = null; } } if (text2 == null) { try { AssemblyDefinition obj3 = AssemblyResolver.Resolve(AssemblyNameReference.Parse(fullName ?? name)); value2 = ((obj3 != null) ? obj3.MainModule : null); } catch { } if (value2 != null) { text2 = value2.FileName; } } if (value2 == null) { if (text2 != null && File.Exists(text2)) { value2 = _ReadModule(text2, GenReaderParameters(mainModule: false, text2)); } else if ((value2 = MissingDependencyResolver?.Invoke(this, main, name, fullName)) == null) { return; } } LogVerbose("[MapDependency] " + ((ModuleReference)main).Name + " -> " + ((ModuleReference)value2).Name + " ((" + fullName + "), (" + name + ")) loaded"); value.Add(value2); if (fullName == null) { fullName = value2.Assembly.FullName; } DependencyCache[fullName] = value2; DependencyCache[name] = value2; MapDependencies(value2); } public virtual ModuleDefinition DefaultMissingDependencyResolver(MonoModder mod, ModuleDefinition main, string name, string fullName) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (MissingDependencyThrow && Environment.GetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW") == "0") { Log("[MissingDependencyResolver] [WARNING] Use MMILRT.Modder.MissingDependencyThrow instead of setting the env var MONOMOD_DEPENDENCY_MISSING_THROW"); MissingDependencyThrow = false; } if (MissingDependencyThrow || Strict) { throw new RelinkTargetNotFoundException("MonoMod cannot map dependency " + ((ModuleReference)main).Name + " -> ((" + fullName + "), (" + name + ")) - not found", (IMetadataTokenProvider)(object)main, (IMetadataTokenProvider)null); } return null; } public virtual void Write(Stream output = null, string outputPath = null) { output = output ?? Output; outputPath = outputPath ?? OutputPath; PatchRefsInType(PatchWasHere()); if (output != null) { Log("[Write] Writing modded module into output stream."); Module.Write(output, WriterParameters); } else { Log("[Write] Writing modded module into output file."); Module.Write(outputPath, WriterParameters); } } public virtual ReaderParameters GenReaderParameters(bool mainModule, string path = null) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown ReaderParameters readerParameters = ReaderParameters; ReaderParameters val = new ReaderParameters(readerParameters.ReadingMode); val.AssemblyResolver = readerParameters.AssemblyResolver; val.MetadataResolver = readerParameters.MetadataResolver; val.InMemory = readerParameters.InMemory; val.MetadataImporterProvider = readerParameters.MetadataImporterProvider; val.ReflectionImporterProvider = readerParameters.ReflectionImporterProvider; val.ThrowIfSymbolsAreNotMatching = readerParameters.ThrowIfSymbolsAreNotMatching; val.ApplyWindowsRuntimeProjections = readerParameters.ApplyWindowsRuntimeProjections; val.SymbolStream = readerParameters.SymbolStream; val.SymbolReaderProvider = readerParameters.SymbolReaderProvider; val.ReadSymbols = readerParameters.ReadSymbols; if (path != null && !File.Exists(path + ".mdb") && !File.Exists(Path.ChangeExtension(path, "pdb"))) { val.ReadSymbols = false; } return val; } public virtual void ReadMod(string path) { if (Directory.Exists(path)) { Log("[ReadMod] Loading mod dir: " + path); string text = ((ModuleReference)Module).Name.Substring(0, ((ModuleReference)Module).Name.Length - 3); string value = text.Replace(" ", ""); if (!DependencyDirs.Contains(path)) { IAssemblyResolver assemblyResolver = AssemblyResolver; IAssemblyResolver obj = ((assemblyResolver is BaseAssemblyResolver) ? assemblyResolver : null); if (obj != null) { ((BaseAssemblyResolver)obj).AddSearchDirectory(path); } DependencyDirs.Add(path); } string[] files = Directory.GetFiles(path); foreach (string text2 in files) { if ((Path.GetFileName(text2).StartsWith(text) || Path.GetFileName(text2).StartsWith(value)) && text2.ToLower().EndsWith(".mm.dll")) { ReadMod(text2); } } return; } Log("[ReadMod] Loading mod: " + path); ModuleDefinition val = _ReadModule(path, GenReaderParameters(mainModule: false, path)); string directoryName = Path.GetDirectoryName(path); if (!DependencyDirs.Contains(directoryName)) { IAssemblyResolver assemblyResolver2 = AssemblyResolver; IAssemblyResolver obj2 = ((assemblyResolver2 is BaseAssemblyResolver) ? assemblyResolver2 : null); if (obj2 != null) { ((BaseAssemblyResolver)obj2).AddSearchDirectory(directoryName); } DependencyDirs.Add(directoryName); } Mods.Add((ModuleReference)(object)val); OnReadMod?.Invoke(this, val); } public virtual void ReadMod(Stream stream) { Log($"[ReadMod] Loading mod: stream#{(uint)stream.GetHashCode()}"); ModuleDefinition val = _ReadModule(stream, GenReaderParameters(mainModule: false)); Mods.Add((ModuleReference)(object)val); OnReadMod?.Invoke(this, val); } public virtual void ParseRules(ModuleDefinition mod) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) TypeDefinition type = mod.GetType("MonoMod.MonoModRules"); Type rulesTypeMMILRT = null; if (type != null) { rulesTypeMMILRT = this.ExecuteRules(type); mod.Types.Remove(type); } Enumerator<TypeDefinition> enumerator = mod.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; ParseRulesInType(current, rulesTypeMMILRT); } } finally { ((IDisposable)enumerator).Dispose(); } } public virtual void ParseRulesInType(TypeDefinition type, Type rulesTypeMMILRT = null) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) Extensions.GetPatchFullName((MemberReference)(object)type); if (!MatchingConditionals((ICustomAttributeProvider)(object)type, Module)) { return; } CustomAttribute customAttribute = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModCustomAttributeAttribute"); CustomAttributeArgument val; if (customAttribute != null) { val = customAttribute.ConstructorArguments[0]; MethodInfo method2 = rulesTypeMMILRT.GetMethod((string)((CustomAttributeArgument)(ref val)).Value); CustomAttributeHandlers[((MemberReference)type).FullName] = delegate(object self, object[] args) { method2.Invoke(self, args); }; } customAttribute = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModCustomMethodAttributeAttribute"); if (customAttribute != null) { val = customAttribute.ConstructorArguments[0]; MethodInfo method = rulesTypeMMILRT.GetMethod((string)((CustomAttributeArgument)(ref val)).Value); ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length == 2 && Extensions.IsCompatible(parameters[0].ParameterType, typeof(ILContext))) { CustomMethodAttributeHandlers[((MemberReference)type).FullName] = delegate(object self, object[] args) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown ILContext il = new ILContext((MethodDefinition)args[0]); il.Invoke((Manipulator)delegate { method.Invoke(self, new object[2] { il, args[1] }); }); if (il.IsReadOnly) { il.Dispose(); } }; } else { CustomMethodAttributeHandlers[((MemberReference)type).FullName] = delegate(object self, object[] args) { method.Invoke(self, args); }; } } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModHook"); val2 != null; val2 = ((ICustomAttributeProvider)(object)type).GetNextCustomAttribute("MonoMod.MonoModHook")) { ParseLinkFrom((MemberReference)(object)type, val2); } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModLinkFrom"); val2 != null; val2 = ((ICustomAttributeProvider)(object)type).GetNextCustomAttribute("MonoMod.MonoModLinkFrom")) { ParseLinkFrom((MemberReference)(object)type, val2); } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModLinkTo"); val2 != null; val2 = ((ICustomAttributeProvider)(object)type).GetNextCustomAttribute("MonoMod.MonoModLinkTo")) { ParseLinkTo((MemberReference)(object)type, val2); } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModIgnore")) { return; } Enumerator<MethodDefinition> enumerator = type.Methods.GetEnumerator(); try { while (enumerator.MoveNext()) { MethodDefinition current = enumerator.Current; if (MatchingConditionals((ICustomAttributeProvider)(object)current, Module)) { for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModHook"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current).GetNextCustomAttribute("MonoMod.MonoModHook")) { ParseLinkFrom((MemberReference)(object)current, val2); } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModLinkFrom"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current).GetNextCustomAttribute("MonoMod.MonoModLinkFrom")) { ParseLinkFrom((MemberReference)(object)current, val2); } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModLinkTo"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current).GetNextCustomAttribute("MonoMod.MonoModLinkTo")) { ParseLinkTo((MemberReference)(object)current, val2); } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModForceCall")) { ForceCallMap[Extensions.GetID((MethodReference)(object)current, (string)null, (string)null, true, false)] = OpCodes.Call; } else if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)current, "MonoMod.MonoModForceCallvirt")) { ForceCallMap[Extensions.GetID((MethodReference)(object)current, (string)null, (string)null, true, false)] = OpCodes.Callvirt; } } } } finally { ((IDisposable)enumerator).Dispose(); } Enumerator<FieldDefinition> enumerator2 = type.Fields.GetEnumerator(); try { while (enumerator2.MoveNext()) { FieldDefinition current2 = enumerator2.Current; if (MatchingConditionals((ICustomAttributeProvider)(object)current2, Module)) { for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current2, "MonoMod.MonoModHook"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current2).GetNextCustomAttribute("MonoMod.MonoModHook")) { ParseLinkFrom((MemberReference)(object)current2, val2); } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current2, "MonoMod.MonoModLinkFrom"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current2).GetNextCustomAttribute("MonoMod.MonoModLinkFrom")) { ParseLinkFrom((MemberReference)(object)current2, val2); } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current2, "MonoMod.MonoModLinkTo"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current2).GetNextCustomAttribute("MonoMod.MonoModLinkTo")) { ParseLinkTo((MemberReference)(object)current2, val2); } } } } finally { ((IDisposable)enumerator2).Dispose(); } Enumerator<PropertyDefinition> enumerator3 = type.Properties.GetEnumerator(); try { while (enumerator3.MoveNext()) { PropertyDefinition current3 = enumerator3.Current; if (MatchingConditionals((ICustomAttributeProvider)(object)current3, Module)) { for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current3, "MonoMod.MonoModHook"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current3).GetNextCustomAttribute("MonoMod.MonoModHook")) { ParseLinkFrom((MemberReference)(object)current3, val2); } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current3, "MonoMod.MonoModLinkFrom"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current3).GetNextCustomAttribute("MonoMod.MonoModLinkFrom")) { ParseLinkFrom((MemberReference)(object)current3, val2); } for (CustomAttribute val2 = Extensions.GetCustomAttribute((ICustomAttributeProvider)(object)current3, "MonoMod.MonoModLinkTo"); val2 != null; val2 = ((ICustomAttributeProvider)(object)current3).GetNextCustomAttribute("MonoMod.MonoModLinkTo")) { ParseLinkTo((MemberReference)(object)current3, val2); } } } } finally { ((IDisposable)enumerator3).Dispose(); } Enumerator<TypeDefinition> enumerator4 = type.NestedTypes.GetEnumerator(); try { while (enumerator4.MoveNext()) { TypeDefinition current4 = enumerator4.Current; ParseRulesInType(current4, rulesTypeMMILRT); } } finally { ((IDisposable)enumerator4).Dispose(); } } public virtual void ParseLinkFrom(MemberReference target, CustomAttribute hook) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) CustomAttributeArgument val = hook.ConstructorArguments[0]; string key = (string)((CustomAttributeArgument)(ref val)).Value; object value; if (target is TypeReference) { value = Extensions.GetPatchFullName((MemberReference)(TypeReference)target); } else if (target is MethodReference) { value = new RelinkMapEntry(Extensions.GetPatchFullName((MemberReference)(object)((MemberReference)(MethodReference)target).DeclaringType), Extensions.GetID((MethodReference)target, (string)null, (string)null, false, false)); } else if (target is FieldReference) { value = new RelinkMapEntry(Extensions.GetPatchFullName((MemberReference)(object)((MemberReference)(FieldReference)target).DeclaringType), ((MemberReference)(FieldReference)target).Name); } else { if (!(target is PropertyReference)) { return; } value = new RelinkMapEntry(Extensions.GetPatchFullName((MemberReference)(object)((MemberReference)(PropertyReference)target).DeclaringType), ((MemberReference)(PropertyReference)target).Name); } RelinkMap[key] = value; } public virtual void ParseLinkTo(MemberReference from, CustomAttribute hook) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) MemberReference obj = ((from is MethodReference) ? from : null); string key = ((obj != null) ? Extensions.GetID((MethodReference)(object)obj, (string)null, (string)null, true, false) : null) ?? Extensions.GetPatchFullName(from); CustomAttributeArgument val; if (hook.ConstructorArguments.Count == 1) { Dictionary<string, object> relinkMap = RelinkMap; val = hook.ConstructorArguments[0]; relinkMap[key] = (string)((CustomAttributeArgument)(ref val)).Value; } else { Dictionary<string, object> relinkMap2 = RelinkMap; val = hook.ConstructorArguments[0]; string type = (string)((CustomAttributeArgument)(ref val)).Value; val = hook.ConstructorArguments[1]; relinkMap2[key] = new RelinkMapEntry(type, (string)((CustomAttributeArgument)(ref val)).Value); } } public virtual void RunCustomAttributeHandlers(ICustomAttributeProvider cap) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown if (!cap.HasCustomAttributes) { return; } CustomAttribute[] array = cap.CustomAttributes.ToArray(); foreach (CustomAttribute val in array) { if (CustomAttributeHandlers.TryGetValue(((MemberReference)val.AttributeType).FullName, out var value)) { value?.Invoke(null, new object[2] { cap, val }); } if (cap is MethodReference && CustomMethodAttributeHandlers.TryGetValue(((MemberReference)val.AttributeType).FullName, out value)) { value?.Invoke(null, new object[2] { (object)(MethodDefinition)cap, val }); } } } public virtual void AutoPatch() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown Log("[AutoPatch] Parsing rules in loaded mods"); foreach (ModuleDefinition mod4 in Mods) { ModuleDefinition mod = mod4; ParseRules(mod); } Log("[AutoPatch] PrePatch pass"); foreach (ModuleDefinition mod5 in Mods) { ModuleDefinition mod2 = mod5; PrePatchModule(mod2); } Log("[AutoPatch] Patch pass"); foreach (ModuleDefinition mod6 in Mods) { ModuleDefinition mod3 = mod6; PatchModule(mod3); } Log("[AutoPatch] PatchRefs pass"); PatchRefs(); if (PostProcessors != null) { Delegate[] invocationList = PostProcessors.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { Log($"[PostProcessor] PostProcessor pass #{i + 1}"); ((PostProcessor)invocationList[i])?.Invoke(this); } } } public virtual IMetadataTokenProvider Relinker(IMetadataTokenProvider mtp, IGenericParameterProvider context) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) try { return PostRelinker(MainRelinker(mtp, context) ?? mtp, context) ?? throw new RelinkTargetNotFoundException(mtp, (IMetadataTokenProvider)(object)context); } catch (Exception ex) { throw new RelinkFailedException((string)null, ex, mtp, (IMetadataTokenProvider)(object)context); } } public virtual IMetadataTokenProvider MainRelinker(IMetadataTokenProvider mtp, IGenericParameterProvider context) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) TypeReference val = (TypeReference)(object)((mtp is TypeReference) ? mtp : null); if (val != null) { if (((MemberReference)val).Module == Module) { return (IMetadataTokenProvider)(object)val; } if (((MemberReference)val).Module != null && !Mods.Contains((ModuleReference)(object)((MemberReference)val).Module)) { return (IMetadataTokenProvider)(object)Module.ImportReference(val); } val = (TypeReference)(((object)Extensions.SafeResolve(val)) ?? ((object)val)); TypeReference val2 = FindTypeDeep(Extensions.GetPatchFullName((MemberReference)(object)val)); if (val2 == null) { if (RelinkMap.ContainsKey(((MemberReference)val).FullName)) { return null; } throw new RelinkTargetNotFoundException(mtp, (IMetadataTokenProvider)(object)context); } return (IMetadataTokenProvider)(object)Module.ImportReference(val2); } if (mtp is FieldReference || mtp is MethodReference || mtp is PropertyReference || mtp is EventReference) { return Extensions.ImportReference(Module, mtp); } throw new InvalidOperationException($"MonoMod default relinker can't handle metadata token providers of the type {((object)mtp).GetType()}"); } public virtual IMetadataTokenProvider PostRelinker(IMetadataTokenProvider mtp, IGenericParameterProvider context) { return ResolveRelinkTarget(mtp) ?? mtp; } public virtual IMetadataTokenProvider ResolveRelinkTarget(IMetadataTokenProvider mtp, bool relink = true, bool relinkModule = true) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown //IL_023c: Expected O, but got Unknown //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) string text = null; string text2; if (mtp is TypeReference) { text2 = ((MemberReference)(TypeReference)mtp).FullName; } else if (mtp is MethodReference) { text2 = Extensions.GetID((MethodReference)mtp, (string)null, (string)null, true, false); text = Extensions.GetID((MethodReference)mtp, (string)null, (string)null, true, true); } else if (mtp is FieldReference) { text2 = ((MemberReference)(FieldReference)mtp).FullName; } else { if (!(mtp is PropertyReference)) { return null; } text2 = ((MemberReference)(PropertyReference)mtp).FullName; } if (RelinkMapCache.TryGetValue(text2, out var value)) { return value; } if (relink && (RelinkMap.TryGetValue(text2, out var value2) || (text != null && RelinkMap.TryGetValue(text, out value2)))) { if (value2 is IMetadataTokenProvider) { return RelinkMapCache[text2] = Extensions.ImportReference(Module, (IMetadataTokenProvider)value2); } if (value2 is RelinkMapEntry) { string type = ((RelinkMapEntry)value2).Type; string findableID = ((RelinkMapEntry)value2).FindableID; TypeReference obj = FindTypeDeep(type); TypeDefinition val2 = ((obj != null) ? Extensions.SafeResolve(obj) : null); if (val2 == null) { return RelinkMapCache[text2] = ResolveRelinkTarget(mtp, relink: false, relinkModule); } value2 = Extensions.FindMethod(val2, findableID, true) ?? ((object)Extensions.FindField(val2, findableID)) ?? ((object)(Extensions.FindProperty(val2, findableID) ?? null)); if (value2 == null) { if (Strict) { throw new RelinkTargetNotFoundException(string.Format("{0} ({1}, {2}) (remap: {3})", "MonoMod relinker failed finding", type, findableID, mtp), mtp, (IMetadataTokenProvider)null); } return null; } return RelinkMapCache[text2] = Extensions.ImportReference(Module, (IMetadataTokenProvider)value2); } if (value2 is string && mtp is TypeReference) { IMetadataTokenProvider val5 = (IMetadataTokenProvider)(object)FindTypeDeep((string)value2); if (val5 == null) { if (Strict) { throw new RelinkTargetNotFoundException(string.Format("{0} {1} (remap: {2})", "MonoMod relinker failed finding", value2, mtp), mtp, (IMetadataTokenProvider)null); } return null; } value2 = Extensions.ImportReference(Module, ResolveRelinkTarget(val5, relink: false, relinkModule) ?? val5); } if (value2 is IMetadataTokenProvider) { Dictionary<string, IMetadataTokenProvider> relinkMapCache = RelinkMapCache; string key = text2; IMetadataTokenProvider val6 = (IMetadataTokenProvider)value2; IMetadataTokenProvider result = val6; relinkMapCache[key] = val6; return result; } throw new InvalidOperationException($"MonoMod doesn't support RelinkMap value of type {value2.GetType()} (remap: {mtp})"); } if (relinkModule && mtp is TypeReference) { if (RelinkModuleMapCache.TryGetValue(text2, out var value3)) { return (IMetadataTokenProvider)(object)value3; } value3 = (TypeReference)mtp; if (RelinkModuleMap.TryGetValue(value3.Scope.Name, out var value4)) { TypeReference type2 = (TypeReference)(object)value4.GetType(((MemberReference)value3).FullName); if (type2 == null) { if (Strict) { throw new RelinkTargetNotFoundException(string.Format("{0} {1} (remap: {2})", "MonoMod relinker failed finding", ((MemberReference)value3).FullName, mtp), mtp, (IMetadataTokenProvider)null); } return null; } return (IMetadataTokenProvider)(object)(RelinkModuleMapCache[text2] = Module.ImportReference(type2)); } return (IMetadataTokenProvider)(object)Module.ImportReference(value3); } return null; } public virtual bool DefaultParser(MonoModder mod, MethodBody body, Instruction instr, ref int instri) { return true; } public virtual TypeReference FindType(string name) { return FindType(Module, name, new Stack<ModuleDefinition>()) ?? Module.GetType(name, false); } public virtual TypeReference FindType(string name, bool runtimeName) { return FindType(Module, name, new Stack<ModuleDefinition>()) ?? Module.GetType(name, runtimeName); } protected virtual TypeReference FindType(ModuleDefinition main, string fullName, Stack<ModuleDefinition> crawled) { TypeReference type; if ((type = main.GetType(fullName, false)) != null) { return type; } if (fullName.StartsWith("<PrivateImplementationDetails>/")) { return null; } if (crawled.Contains(main)) { return null; } crawled.Push(main); foreach (ModuleDefinition item in DependencyMap[main]) { if ((!RemovePatchReferences || !((AssemblyNameReference)item.Assembly.Name).Name.EndsWith(".mm")) && (type = FindType(item, fullName, crawled)) != null) { return type; } } return null; } public virtual TypeReference FindTypeDeep(string name) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown TypeReference val = FindType(name, runtimeName: false); if (val != null) { return val; } Stack<ModuleDefinition> crawled = new Stack<ModuleDefinition>(); val = null; foreach (ModuleDefinition mod in Mods) { ModuleDefinition key = mod; foreach (ModuleDefinition item in DependencyMap[key]) { if ((val = FindType(item, name, crawled)) != null) { IMetadataScope scope = val.Scope; AssemblyNameReference dllRef = (AssemblyNameReference)(object)((scope is AssemblyNameReference) ? scope : null); if (dllRef != null && !((IEnumerable<AssemblyNameReference>)Module.AssemblyReferences).Any((AssemblyNameReference n) => n.Name == dllRef.Name)) { Module.AssemblyReferences.Add(dllRef); } return Module.ImportReference(val); } } } return null; } public virtual void PrePatchModule(ModuleDefinition mod) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown Enumerator<TypeDefinition> enumerator = mod.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; PrePatchType(current); } } finally { ((IDisposable)enumerator).Dispose(); } Enumerator<ModuleReference> enumerator2 = mod.ModuleReferences.GetEnumerator(); try { while (enumerator2.MoveNext()) { ModuleReference current2 = enumerator2.Current; if (!Module.ModuleReferences.Contains(current2)) { Module.ModuleReferences.Add(current2); } } } finally { ((IDisposable)enumerator2).Dispose(); } Enumerator<Resource> enumerator3 = mod.Resources.GetEnumerator(); try { while (enumerator3.MoveNext()) { Resource current3 = enumerator3.Current; if (current3 is EmbeddedResource) { Module.Resources.Add((Resource)new EmbeddedResource(current3.Name.StartsWith(((AssemblyNameReference)mod.Assembly.Name).Name) ? (((AssemblyNameReference)Module.Assembly.Name).Name + current3.Name.Substring(((AssemblyNameReference)mod.Assembly.Name).Name.Length)) : current3.Name, current3.Attributes, ((EmbeddedResource)current3).GetResourceData())); } } } finally { ((IDisposable)enumerator3).Dispose(); } } public virtual void PrePatchType(TypeDefinition type, bool forceAdd = false) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown string patchFullName = Extensions.GetPatchFullName((MemberReference)(object)type); if ((((TypeReference)type).Namespace != "MonoMod" && Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModIgnore")) || SkipList.Contains(patchFullName) || !MatchingConditionals((ICustomAttributeProvider)(object)type, Module) || (((MemberReference)type).FullName == "MonoMod.MonoModRules" && !forceAdd)) { return; } TypeReference val = (forceAdd ? null : Module.GetType(patchFullName, false)); TypeDefinition val2 = ((val != null) ? Extensions.SafeResolve(val) : null); if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModReplace") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModRemove")) { if (val2 != null) { if (val2.DeclaringType == null) { Module.Types.Remove(val2); } else { val2.DeclaringType.NestedTypes.Remove(val2); } } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModRemove")) { return; } } else if (val != null) { PrePatchNested(type); return; } LogVerbose("[PrePatchType] Adding " + patchFullName + " to the target module."); TypeDefinition val3 = new TypeDefinition(((TypeReference)type).Namespace, ((MemberReference)type).Name, type.Attributes, type.BaseType); Enumerator<GenericParameter> enumerator = ((TypeReference)type).GenericParameters.GetEnumerator(); try { while (enumerator.MoveNext()) { GenericParameter current = enumerator.Current; ((TypeReference)val3).GenericParameters.Add(Extensions.Clone(current)); } } finally { ((IDisposable)enumerator).Dispose(); } Enumerator<InterfaceImplementation> enumerator2 = type.Interfaces.GetEnumerator(); try { while (enumerator2.MoveNext()) { InterfaceImplementation current2 = enumerator2.Current; val3.Interfaces.Add(current2); } } finally { ((IDisposable)enumerator2).Dispose(); } val3.ClassSize = type.ClassSize; if (type.DeclaringType != null) { val3.DeclaringType = Extensions.Relink((TypeReference)(object)type.DeclaringType, new Relinker(Relinker), (IGenericParameterProvider)(object)val3).Resolve(); val3.DeclaringType.NestedTypes.Add(val3); } else { Module.Types.Add(val3); } val3.PackingSize = type.PackingSize; Extensions.AddRange<SecurityDeclaration>(val3.SecurityDeclarations, (IEnumerable<SecurityDeclaration>)type.SecurityDeclarations); val3.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor())); val = (TypeReference)(object)val3; PrePatchNested(type); } protected virtual void PrePatchNested(TypeDefinition type) { for (int i = 0; i < type.NestedTypes.Count; i++) { PrePatchType(type.NestedTypes[i]); } } public virtual void PatchModule(ModuleDefinition mod) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) Enumerator<TypeDefinition> enumerator = mod.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; if ((((TypeReference)current).Namespace == "MonoMod" || ((TypeReference)current).Namespace.StartsWith("MonoMod.")) && ((MemberReference)current.BaseType).FullName == "System.Attribute") { PatchType(current); } } } finally { ((IDisposable)enumerator).Dispose(); } enumerator = mod.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current2 = enumerator.Current; if ((!(((TypeReference)current2).Namespace == "MonoMod") && !((TypeReference)current2).Namespace.StartsWith("MonoMod.")) || !(((MemberReference)current2.BaseType).FullName == "System.Attribute")) { PatchType(current2); } } } finally { ((IDisposable)enumerator).Dispose(); } } public virtual void PatchType(TypeDefinition type) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) string patchFullName = Extensions.GetPatchFullName((MemberReference)(object)type); TypeReference type2 = Module.GetType(patchFullName, false); if (type2 == null) { return; } TypeDefinition val = ((type2 != null) ? Extensions.SafeResolve(type2) : null); Enumerator<CustomAttribute> enumerator; if ((((TypeReference)type).Namespace != "MonoMod" && Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModIgnore")) || SkipList.Contains(patchFullName) || !MatchingConditionals((ICustomAttributeProvider)(object)type, Module)) { if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModIgnore") && val != null) { enumerator = type.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current = enumerator.Current; if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName)) { val.CustomAttributes.Add(Extensions.Clone(current)); } } } finally { ((IDisposable)enumerator).Dispose(); } } PatchNested(type); return; } if (patchFullName == ((MemberReference)type).FullName) { LogVerbose("[PatchType] Patching type " + patchFullName); } else { LogVerbose("[PatchType] Patching type " + patchFullName + " (prefixed: " + ((MemberReference)type).FullName + ")"); } enumerator = type.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current2 = enumerator.Current; if (!Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)val, ((MemberReference)current2.AttributeType).FullName)) { val.CustomAttributes.Add(Extensions.Clone(current2)); } } } finally { ((IDisposable)enumerator).Dispose(); } HashSet<MethodDefinition> hashSet = new HashSet<MethodDefinition>(); Enumerator<PropertyDefinition> enumerator2 = type.Properties.GetEnumerator(); try { while (enumerator2.MoveNext()) { PropertyDefinition current3 = enumerator2.Current; PatchProperty(val, current3, hashSet); } } finally { ((IDisposable)enumerator2).Dispose(); } HashSet<MethodDefinition> hashSet2 = new HashSet<MethodDefinition>(); Enumerator<EventDefinition> enumerator3 = type.Events.GetEnumerator(); try { while (enumerator3.MoveNext()) { EventDefinition current4 = enumerator3.Current; PatchEvent(val, current4, hashSet2); } } finally { ((IDisposable)enumerator3).Dispose(); } Enumerator<MethodDefinition> enumerator4 = type.Methods.GetEnumerator(); try { while (enumerator4.MoveNext()) { MethodDefinition current5 = enumerator4.Current; if (!hashSet.Contains(current5) && !hashSet2.Contains(current5)) { PatchMethod(val, current5); } } } finally { ((IDisposable)enumerator4).Dispose(); } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)type, "MonoMod.MonoModEnumReplace")) { int num = 0; while (num < val.Fields.Count) { if (((MemberReference)val.Fields[num]).Name == "value__") { num++; } else { val.Fields.RemoveAt(num); } } } Enumerator<FieldDefinition> enumerator5 = type.Fields.GetEnumerator(); try { while (enumerator5.MoveNext()) { FieldDefinition current6 = enumerator5.Current; PatchField(val, current6); } } finally { ((IDisposable)enumerator5).Dispose(); } PatchNested(type); } protected virtual void PatchNested(TypeDefinition type) { for (int i = 0; i < type.NestedTypes.Count; i++) { PatchType(type.NestedTypes[i]); } } public virtual void PatchProperty(TypeDefinition targetType, PropertyDefinition prop, HashSet<MethodDefinition> propMethods = null) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Expected O, but got Unknown //IL_022b: Expected O, but got Unknown //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Expected O, but got Unknown //IL_02b5: Expected O, but got Unknown //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) if (!MatchingConditionals((ICustomAttributeProvider)(object)prop, Module)) { return; } ((MemberReference)prop).Name = Extensions.GetPatchName((MemberReference)(object)prop); PropertyDefinition val = Extensions.FindProperty(targetType, ((MemberReference)prop).Name); string text = "<" + ((MemberReference)prop).Name + ">__BackingField"; FieldDefinition val2 = Extensions.FindField(prop.DeclaringType, text); FieldDefinition val3 = Extensions.FindField(targetType, text); Enumerator<CustomAttribute> enumerator; Enumerator<MethodDefinition> enumerator2; if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)prop, "MonoMod.MonoModIgnore")) { if (val != null) { enumerator = prop.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current = enumerator.Current; if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName)) { val.CustomAttributes.Add(Extensions.Clone(current)); } } } finally { ((IDisposable)enumerator).Dispose(); } } if (val2 != null) { val2.DeclaringType.Fields.Remove(val2); } if (prop.GetMethod != null) { propMethods?.Add(prop.GetMethod); } if (prop.SetMethod != null) { propMethods?.Add(prop.SetMethod); } enumerator2 = prop.OtherMethods.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodDefinition current2 = enumerator2.Current; propMethods?.Add(current2); } return; } finally { ((IDisposable)enumerator2).Dispose(); } } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)prop, "MonoMod.MonoModRemove") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)prop, "MonoMod.MonoModReplace")) { if (val != null) { targetType.Properties.Remove(val); if (val3 != null) { targetType.Fields.Remove(val3); } if (val.GetMethod != null) { targetType.Methods.Remove(val.GetMethod); } if (val.SetMethod != null) { targetType.Methods.Remove(val.SetMethod); } enumerator2 = val.OtherMethods.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodDefinition current3 = enumerator2.Current; targetType.Methods.Remove(current3); } } finally { ((IDisposable)enumerator2).Dispose(); } } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)prop, "MonoMod.MonoModRemove")) { return; } } if (val == null) { PropertyDefinition val4 = new PropertyDefinition(((MemberReference)prop).Name, prop.Attributes, ((PropertyReference)prop).PropertyType); val = val4; PropertyDefinition val5 = val4; val5.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor())); Enumerator<ParameterDefinition> enumerator3 = ((PropertyReference)prop).Parameters.GetEnumerator(); try { while (enumerator3.MoveNext()) { ParameterDefinition current4 = enumerator3.Current; ((PropertyReference)val5).Parameters.Add(Extensions.Clone(current4)); } } finally { ((IDisposable)enumerator3).Dispose(); } val5.DeclaringType = targetType; targetType.Properties.Add(val5); if (val2 != null) { FieldDefinition val6 = new FieldDefinition(text, val2.Attributes, ((FieldReference)val2).FieldType); val3 = val6; FieldDefinition val7 = val6; targetType.Fields.Add(val7); } } enumerator = prop.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current5 = enumerator.Current; val.CustomAttributes.Add(Extensions.Clone(current5)); } } finally { ((IDisposable)enumerator).Dispose(); } MethodDefinition getMethod = prop.GetMethod; MethodDefinition getMethod2; if (getMethod != null && (getMethod2 = PatchMethod(targetType, getMethod)) != null) { val.GetMethod = getMethod2; propMethods?.Add(getMethod); } MethodDefinition setMethod = prop.SetMethod; if (setMethod != null && (getMethod2 = PatchMethod(targetType, setMethod)) != null) { val.SetMethod = getMethod2; propMethods?.Add(setMethod); } enumerator2 = prop.OtherMethods.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodDefinition current6 = enumerator2.Current; if ((getMethod2 = PatchMethod(targetType, current6)) != null) { val.OtherMethods.Add(getMethod2); propMethods?.Add(current6); } } } finally { ((IDisposable)enumerator2).Dispose(); } } public virtual void PatchEvent(TypeDefinition targetType, EventDefinition srcEvent, HashSet<MethodDefinition> propMethods = null) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_0252: Expected O, but got Unknown //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) ((MemberReference)srcEvent).Name = Extensions.GetPatchName((MemberReference)(object)srcEvent); EventDefinition val = Extensions.FindEvent(targetType, ((MemberReference)srcEvent).Name); string text = "<" + ((MemberReference)srcEvent).Name + ">__BackingField"; FieldDefinition val2 = Extensions.FindField(srcEvent.DeclaringType, text); FieldDefinition val3 = Extensions.FindField(targetType, text); Enumerator<CustomAttribute> enumerator; Enumerator<MethodDefinition> enumerator2; if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)srcEvent, "MonoMod.MonoModIgnore")) { if (val != null) { enumerator = srcEvent.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current = enumerator.Current; if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName)) { val.CustomAttributes.Add(Extensions.Clone(current)); } } } finally { ((IDisposable)enumerator).Dispose(); } } if (val2 != null) { val2.DeclaringType.Fields.Remove(val2); } if (srcEvent.AddMethod != null) { propMethods?.Add(srcEvent.AddMethod); } if (srcEvent.RemoveMethod != null) { propMethods?.Add(srcEvent.RemoveMethod); } if (srcEvent.InvokeMethod != null) { propMethods?.Add(srcEvent.InvokeMethod); } enumerator2 = srcEvent.OtherMethods.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodDefinition current2 = enumerator2.Current; propMethods?.Add(current2); } return; } finally { ((IDisposable)enumerator2).Dispose(); } } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)srcEvent, "MonoMod.MonoModRemove") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)srcEvent, "MonoMod.MonoModReplace")) { if (val != null) { targetType.Events.Remove(val); if (val3 != null) { targetType.Fields.Remove(val3); } if (val.AddMethod != null) { targetType.Methods.Remove(val.AddMethod); } if (val.RemoveMethod != null) { targetType.Methods.Remove(val.RemoveMethod); } if (val.InvokeMethod != null) { targetType.Methods.Remove(val.InvokeMethod); } if (val.OtherMethods != null) { enumerator2 = val.OtherMethods.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodDefinition current3 = enumerator2.Current; targetType.Methods.Remove(current3); } } finally { ((IDisposable)enumerator2).Dispose(); } } } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)srcEvent, "MonoMod.MonoModRemove")) { return; } } if (val == null) { EventDefinition val4 = new EventDefinition(((MemberReference)srcEvent).Name, srcEvent.Attributes, ((EventReference)srcEvent).EventType); val = val4; EventDefinition val5 = val4; val5.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor())); val5.DeclaringType = targetType; targetType.Events.Add(val5); if (val2 != null) { FieldDefinition val6 = new FieldDefinition(text, val2.Attributes, ((FieldReference)val2).FieldType); targetType.Fields.Add(val6); } } enumerator = srcEvent.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current4 = enumerator.Current; val.CustomAttributes.Add(Extensions.Clone(current4)); } } finally { ((IDisposable)enumerator).Dispose(); } MethodDefinition addMethod = srcEvent.AddMethod; MethodDefinition addMethod2; if (addMethod != null && (addMethod2 = PatchMethod(targetType, addMethod)) != null) { val.AddMethod = addMethod2; propMethods?.Add(addMethod); } MethodDefinition removeMethod = srcEvent.RemoveMethod; if (removeMethod != null && (addMethod2 = PatchMethod(targetType, removeMethod)) != null) { val.RemoveMethod = addMethod2; propMethods?.Add(removeMethod); } MethodDefinition invokeMethod = srcEvent.InvokeMethod; if (invokeMethod != null && (addMethod2 = PatchMethod(targetType, invokeMethod)) != null) { val.InvokeMethod = addMethod2; propMethods?.Add(invokeMethod); } enumerator2 = srcEvent.OtherMethods.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodDefinition current5 = enumerator2.Current; if ((addMethod2 = PatchMethod(targetType, current5)) != null) { val.OtherMethods.Add(addMethod2); propMethods?.Add(current5); } } } finally { ((IDisposable)enumerator2).Dispose(); } } public virtual void PatchField(TypeDefinition targetType, FieldDefinition field) { //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) string patchFullName = Extensions.GetPatchFullName((MemberReference)(object)field.DeclaringType); if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModNoNew") || SkipList.Contains(patchFullName + "::" + ((MemberReference)field).Name) || !MatchingConditionals((ICustomAttributeProvider)(object)field, Module)) { return; } ((MemberReference)field).Name = Extensions.GetPatchName((MemberReference)(object)field); if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModRemove") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModReplace")) { FieldDefinition val = Extensions.FindField(targetType, ((MemberReference)field).Name); if (val != null) { targetType.Fields.Remove(val); } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModRemove")) { return; } } FieldDefinition val2 = Extensions.FindField(targetType, ((MemberReference)field).Name); Enumerator<CustomAttribute> enumerator; if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)field, "MonoMod.MonoModIgnore") && val2 != null) { enumerator = field.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current = enumerator.Current; if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName)) { val2.CustomAttributes.Add(Extensions.Clone(current)); } } return; } finally { ((IDisposable)enumerator).Dispose(); } } if (val2 == null) { val2 = new FieldDefinition(((MemberReference)field).Name, field.Attributes, ((FieldReference)field).FieldType); val2.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor())); val2.InitialValue = field.InitialValue; if (field.HasConstant) { val2.Constant = field.Constant; } targetType.Fields.Add(val2); } enumerator = field.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current2 = enumerator.Current; val2.CustomAttributes.Add(Extensions.Clone(current2)); } } finally { ((IDisposable)enumerator).Dispose(); } } public virtual MethodDefinition PatchMethod(TypeDefinition targetType, MethodDefinition method) { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Expected O, but got Unknown //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Expected O, but got Unknown //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_069a: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Expected O, but got Unknown //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0635: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Expected O, but got Unknown if (((MemberReference)method).Name.StartsWith("orig_") || Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModOriginal")) { return null; } if (!AllowedSpecialName(method, targetType) || !MatchingConditionals((ICustomAttributeProvider)(object)method, Module)) { return null; } string patchFullName = Extensions.GetPatchFullName((MemberReference)(object)targetType); if (SkipList.Contains(Extensions.GetID((MethodReference)(object)method, (string)null, patchFullName, true, false))) { return null; } ((MemberReference)method).Name = Extensions.GetPatchName((MemberReference)(object)method); if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModConstructor")) { if (!method.IsSpecialName && !Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModOriginalName")) { CustomAttribute val = new CustomAttribute(GetMonoModOriginalNameCtor()); val.ConstructorArguments.Add(new CustomAttributeArgument(Module.TypeSystem.String, (object)("orig_" + ((MemberReference)method).Name))); method.CustomAttributes.Add(val); } ((MemberReference)method).Name = (method.IsStatic ? ".cctor" : ".ctor"); method.IsSpecialName = true; method.IsRuntimeSpecialName = true; } MethodDefinition val2 = Extensions.FindMethod(targetType, Extensions.GetID((MethodReference)(object)method, (string)null, patchFullName, true, false), true); MethodDefinition obj = method; string text = patchFullName; MethodDefinition val3 = Extensions.FindMethod(targetType, Extensions.GetID((MethodReference)(object)obj, method.GetOriginalName(), text, true, false), true); if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModIgnore")) { if (val2 != null) { Enumerator<CustomAttribute> enumerator = method.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current = enumerator.Current; if (CustomAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName) || CustomMethodAttributeHandlers.ContainsKey(((MemberReference)current.AttributeType).FullName)) { val2.CustomAttributes.Add(Extensions.Clone(current)); } } } finally { ((IDisposable)enumerator).Dispose(); } } return null; } if (val2 == null && Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModNoNew")) { return null; } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModRemove")) { if (val2 != null) { targetType.Methods.Remove(val2); } return null; } if (Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModReplace")) { if (val2 != null) { val2.CustomAttributes.Clear(); val2.Attributes = method.Attributes; val2.IsPInvokeImpl = method.IsPInvokeImpl; val2.ImplAttributes = method.ImplAttributes; } } else if (val2 != null && val3 == null) { val3 = Extensions.Clone(val2, (MethodDefinition)null); ((MemberReference)val3).Name = method.GetOriginalName(); val3.Attributes = (MethodAttributes)(val2.Attributes & 0xF7FF & 0xEFFF); ((MemberReference)val3).MetadataToken = GetMetadataToken((TokenType)100663296); val3.IsVirtual = false; val3.Overrides.Clear(); Enumerator<MethodReference> enumerator2 = method.Overrides.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodReference current2 = enumerator2.Current; val3.Overrides.Add(current2); } } finally { ((IDisposable)enumerator2).Dispose(); } val3.CustomAttributes.Add(new CustomAttribute(GetMonoModOriginalCtor())); MethodDefinition val4 = Extensions.FindMethod(method.DeclaringType, Extensions.GetID((MethodReference)(object)method, method.GetOriginalName(), (string)null, true, false), true); if (val4 != null) { Enumerator<CustomAttribute> enumerator = val4.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current3 = enumerator.Current; if (CustomAttributeHandlers.ContainsKey(((MemberReference)current3.AttributeType).FullName) || CustomMethodAttributeHandlers.ContainsKey(((MemberReference)current3.AttributeType).FullName)) { val3.CustomAttributes.Add(Extensions.Clone(current3)); } } } finally { ((IDisposable)enumerator).Dispose(); } } targetType.Methods.Add(val3); } if (val3 != null && method.IsConstructor && method.IsStatic && method.HasBody && !Extensions.HasCustomAttribute((ICustomAttributeProvider)(object)method, "MonoMod.MonoModConstructor")) { Collection<Instruction> instructions = method.Body.Instructions; ILProcessor iLProcessor = method.Body.GetILProcessor(); iLProcessor.InsertBefore(instructions[instructions.Count - 1], iLProcessor.Create(OpCodes.Call, (MethodReference)(object)val3)); } if (val2 != null) { val2.Body = Extensions.Clone(method.Body, val2); val2.IsManaged = method.IsManaged; val2.IsIL = method.IsIL; val2.IsNative = method.IsNative; val2.PInvokeInfo = method.PInvokeInfo; val2.IsPreserveSig = method.IsPreserveSig; val2.IsInternalCall = method.IsInternalCall; val2.IsPInvokeImpl = method.IsPInvokeImpl; Enumerator<CustomAttribute> enumerator = method.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current4 = enumerator.Current; val2.CustomAttributes.Add(Extensions.Clone(current4)); } } finally { ((IDisposable)enumerator).Dispose(); } method = val2; } else { MethodDefinition val5 = new MethodDefinition(((MemberReference)method).Name, method.Attributes, Module.TypeSystem.Void); ((MemberReference)val5).MetadataToken = GetMetadataToken((TokenType)100663296); ((MethodReference)val5).CallingConvention = ((MethodReference)method).CallingConvention; ((MethodReference)val5).ExplicitThis = ((MethodReference)method).ExplicitThis; ((MethodReference)val5).MethodReturnType = ((MethodReference)method).MethodReturnType; val5.Attributes = method.Attributes; val5.ImplAttributes = method.ImplAttributes; val5.SemanticsAttributes = method.SemanticsAttributes; val5.DeclaringType = targetType; ((MethodReference)val5).ReturnType = ((MethodReference)method).ReturnType; val5.Body = Extensions.Clone(method.Body, val5); val5.PInvokeInfo = method.PInvokeInfo; val5.IsPInvokeImpl = method.IsPInvokeImpl; Enumerator<GenericParameter> enumerator3 = ((MethodReference)method).GenericParameters.GetEnumerator(); try { while (enumerator3.MoveNext()) { GenericParameter current5 = enumerator3.Current; ((MethodReference)val5).GenericParameters.Add(Extensions.Clone(current5)); } } finally { ((IDisposable)enumerator3).Dispose(); } Enumerator<ParameterDefinition> enumerator4 = ((MethodReference)method).Parameters.GetEnumerator(); try { while (enumerator4.MoveNext()) { ParameterDefinition current6 = enumerator4.Current; ((MethodReference)val5).Parameters.Add(Extensions.Clone(current6)); } } finally { ((IDisposable)enumerator4).Dispose(); } Enumerator<CustomAttribute> enumerator = method.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current7 = enumerator.Current; val5.CustomAttributes.Add(Extensions.Clone(current7)); } } finally { ((IDisposable)enumerator).Dispose(); } Enumerator<MethodReference> enumerator2 = method.Overrides.GetEnumerator(); try { while (enumerator2.MoveNext()) { MethodReference current8 = enumerator2.Current; val5.Overrides.Add(current8); } } finally { ((IDisposable)enumerator2).Dispose(); } val5.CustomAttributes.Add(new CustomAttribute(GetMonoModAddedCtor())); targetType.Methods.Add(val5); method = val5; } if (val3 != null) { CustomAttribute val6 = new CustomAttribute(GetMonoModOriginalNameCtor()); val6.ConstructorArguments.Add(new CustomAttributeArgument(Module.TypeSystem.String, (object)((MemberReference)val3).Name)); method.CustomAttributes.Add(val6); } return method; } public virtual void PatchRefs() { //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) if (!UpgradeMSCORLIB.HasValue) { Version fckUnity = new Version(2, 0, 5, 0); UpgradeMSCORLIB = ((IEnumerable<AssemblyNameReference>)Module.AssemblyReferences).Any((AssemblyNameReference x) => x.Version == fckUnity); } if (UpgradeMSCORLIB.Value) { List<AssemblyNameReference> list = new List<AssemblyNameReference>(); for (int i = 0; i < Module.AssemblyReferences.Count; i++) { AssemblyNameReference val = Module.AssemblyReferences[i]; if (val.Name == "mscorlib") { list.Add(val); } } if (list.Count > 1) { AssemblyNameReference val2 = list.OrderByDescending((AssemblyNameReference x) => x.Version).First(); if (DependencyCache.TryGetValue(val2.FullName, out var value)) { for (int j = 0; j < Module.AssemblyReferences.Count; j++) { AssemblyNameReference val3 = Module.AssemblyReferences[j]; if (val3.Name == "mscorlib" && val2.Version > val3.Version) { LogVerbose("[PatchRefs] Removing and relinking duplicate mscorlib: " + val3.Version); RelinkModuleMap[val3.FullName] = value; Module.AssemblyReferences.RemoveAt(j); j--; } } } } } Enumerator<TypeDefinition> enumerator = Module.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; PatchRefsInType(current); } } finally { ((IDisposable)enumerator).Dispose(); } } public virtual void PatchRefs(ModuleDefinition mod) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Enumerator<TypeDefinition> enumerator = mod.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; PatchRefsInType(current); } } finally { ((IDisposable)enumerator).Dispose(); } } public virtual void PatchRefsInType(TypeDefinition type) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Expected O, but got Unknown //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Expected O, but got Unknown LogVerbose($"[VERBOSE] [PatchRefsInType] Patching refs in {type}"); if (type.BaseType != null) { type.BaseType = Extensions.Relink(type.BaseType, new Relinker(Relinker), (IGenericParameterProvider)(object)type); } for (int i = 0; i < ((TypeReference)type).GenericParameters.Count; i++) { ((TypeReference)type).GenericParameters[i] = Extensions.Relink(((TypeReference)type).GenericParameters[i], new Relinker(Relinker), (IGenericParameterProvider)(object)type); } for (int j = 0; j < type.Interfaces.Count; j++) { InterfaceImplementation obj = type.Interfaces[j]; InterfaceImplementation val = new InterfaceImplementation(Extensions.Relink(obj.InterfaceType, new Relinker(Relinker), (IGenericParameterProvider)(object)type)); Enumerator<CustomAttribute> enumerator = obj.CustomAttributes.GetEnumerator(); try { while (enumerator.MoveNext()) { CustomAttribute current = enumerator.Current; val.CustomAttributes.Add(Extensions.Relink(current, new Relinker(Relinker), (IGenericParameterProvider)(object)type)); } } finally { ((IDisposable)enumerator).Dispose(); } type.Interfaces[j] = val; } for (int k = 0; k < type.CustomAttributes.Count; k++) { type.CustomAttributes[k] = Extensions.Relink(type.CustomAttributes[k], new Relinker(Relinker), (IGenericParameterProvider)(object)type); } Enumerator<PropertyDefinition> enumerator2 = type.Properties.GetEnumerator(); try { while (enumerator2.MoveNext()) { PropertyDefinition current2 = enumerator2.Current; ((PropertyReference)current2).PropertyType = Extensions.Relink(((PropertyReference)current2).PropertyType, new Relinker(Relinker), (IGenericParameterProvider)(object)type); for (int l = 0; l < current2.CustomAttributes.Count; l++) { current2.CustomAttributes[l] = Extensions.Relink(current2.CustomAttributes[l], new Relinker(Relinker), (IGenericParameterProvider)(object)type); } } } finally { ((IDisposable)enumerator2).Dispose(); } Enumerator<EventDefinition> enumerator3 = type.Events.GetEnumerator(); try { while (enumerator3.MoveNext()) { EventDefinition current3 = enumerator3.Current; ((EventReference)current3).EventType = Extensions.Relink(((EventReference)current3).EventType, new Relinker(Relinker), (IGenericParameterProvider)(object)type); for (int m = 0; m < current3.CustomAttributes.Count; m++) { current3.CustomAttributes[m] = Extensions.Relink(current3.CustomAttributes[m], new Relinker(Relinker), (IGenericParameterProvider)(object)type); } } } finally { ((IDisposable)enumerator3).Dispose(); } Enumerator<MethodDefinition> enumerator4 = type.Methods.GetEnumerator(); try { while (enumerator4.MoveNext()) { MethodDefinition current4 = enumerator4.Current; PatchRefsInMethod(current4); } } finally { ((IDisposable)enumerator4).Dispose(); } Enumerator<FieldDefinition> enumerator5 = type.Fields.GetEnumerator(); try { while (enumerator5.MoveNext()) { FieldDefinition current5 = enumerator5.Current; ((FieldReference)current5).FieldType = Extensions.Relink(((FieldReference)current5).FieldType, new Relinker(Relinker), (IGenericParameterProvider)(object)type); for (int n = 0; n < current5.CustomAttributes.Count; n++) { current5.CustomAttributes[n] = Extensions.Relink(current5.CustomAttributes[n], new Relinker(Relinker), (IGenericParameterProvider)(object)type); } } } finally { ((IDisposable)enumerator5).Dispose(); } for (int num = 0; num < type.NestedTypes.Count; num++) { PatchRefsInType(type.NestedTypes[num]); } } public virtual void PatchRefsInMethod(MethodDefinition method) { //IL_0030: Unknown result t
patchers/BepInEx.MonoMod.HookGenPatcher/MonoMod.RuntimeDetour.HookGen.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.Utils; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("0x0ade")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright 2021 0x0ade")] [assembly: AssemblyDescription("Auto-generate hook helper .dlls, hook arbitrary methods via events: On.Namespace.Type.Method += YourHandlerHere;")] [assembly: AssemblyFileVersion("21.8.5.1")] [assembly: AssemblyInformationalVersion("21.08.05.01")] [assembly: AssemblyProduct("MonoMod.RuntimeDetour.HookGen")] [assembly: AssemblyTitle("MonoMod.RuntimeDetour.HookGen")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("21.8.5.1")] [module: UnverifiableCode] internal static class MultiTargetShims { private static readonly object[] _NoArgs = new object[0]; public static TypeReference GetConstraintType(this TypeReference type) { return type; } } namespace MonoMod { internal static class MMDbgLog { public static readonly string Tag; public static TextWriter Writer; public static bool Debugging; static MMDbgLog() { Tag = typeof(MMDbgLog).Assembly.GetName().Name; if (Environment.GetEnvironmentVariable("MONOMOD_DBGLOG") == "1" || (Environment.GetEnvironmentVariable("MONOMOD_DBGLOG")?.ToLowerInvariant()?.Contains(Tag.ToLowerInvariant())).GetValueOrDefault()) { Start(); } } public static void WaitForDebugger() { if (!Debugging) { Debugging = true; Debugger.Launch(); Thread.Sleep(6000); Debugger.Break(); } } public static void Start() { if (Writer != null) { return; } string text = Environment.GetEnvironmentVariable("MONOMOD_DBGLOG_PATH"); if (text == "-") { Writer = Console.Out; return; } if (string.IsNullOrEmpty(text)) { text = "mmdbglog.txt"; } text = Path.GetFullPath(Path.GetFileNameWithoutExtension(text) + "-" + Tag + Path.GetExtension(text)); try { if (File.Exists(text)) { File.Delete(text); } } catch { } try { string directoryName = Path.GetDirectoryName(text); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } Writer = new StreamWriter(new FileStream(text, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete), Encoding.UTF8); } catch { } } public static void Log(string str) { TextWriter writer = Writer; if (writer != null) { writer.WriteLine(str); writer.Flush(); } } public static T Log<T>(string str, T value) { TextWriter writer = Writer; if (writer == null) { return value; } writer.WriteLine(string.Format(str, value)); writer.Flush(); return value; } } } namespace MonoMod.RuntimeDetour.HookGen { public class HookGenerator { private const string ObsoleteMessageBackCompat = "This method only exists for backwards-compatibility purposes."; private static readonly Regex NameVerifyRegex; private static readonly Dictionary<Type, string> ReflTypeNameMap; private static readonly Dictionary<string, string> TypeNameMap; public MonoModder Modder; public ModuleDefinition OutputModule; public string Namespace; public string NamespaceIL; public bool HookOrig; public bool HookPrivate; public string HookExtName; public ModuleDefinition module_RuntimeDetour; public ModuleDefinition module_Utils; public TypeReference t_MulticastDelegate; public TypeReference t_IAsyncResult; public TypeReference t_AsyncCallback; public TypeReference t_MethodBase; public TypeReference t_RuntimeMethodHandle; public TypeReference t_EditorBrowsableState; public MethodReference m_Object_ctor; public MethodReference m_ObsoleteAttribute_ctor; public MethodReference m_EditorBrowsableAttribute_ctor; public MethodReference m_GetMethodFromHandle; public MethodReference m_Add; public MethodReference m_Remove; public MethodReference m_Modify; public MethodReference m_Unmodify; public TypeReference t_ILManipulator; static HookGenerator() { NameVerifyRegex = new Regex("[^a-zA-Z]"); ReflTypeNameMap = new Dictionary<Type, string> { { typeof(string), "string" }, { typeof(object), "object" }, { typeof(bool), "bool" }, { typeof(byte), "byte" }, { typeof(char), "char" }, { typeof(decimal), "decimal" }, { typeof(double), "double" }, { typeof(short), "short" }, { typeof(int), "int" }, { typeof(long), "long" }, { typeof(sbyte), "sbyte" }, { typeof(float), "float" }, { typeof(ushort), "ushort" }, { typeof(uint), "uint" }, { typeof(ulong), "ulong" }, { typeof(void), "void" } }; TypeNameMap = new Dictionary<string, string>(); foreach (KeyValuePair<Type, string> item in ReflTypeNameMap) { TypeNameMap[item.Key.FullName] = item.Value; } } public HookGenerator(MonoModder modder, string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Expected O, but got Unknown //IL_0326: Expected O, but got Unknown Modder = modder; OutputModule = ModuleDefinition.CreateModule(name, new ModuleParameters { Architecture = modder.Module.Architecture, AssemblyResolver = modder.Module.AssemblyResolver, Kind = (ModuleKind)0, Runtime = modder.Module.Runtime }); modder.MapDependencies(); Extensions.AddRange<AssemblyNameReference>(OutputModule.AssemblyReferences, (IEnumerable<AssemblyNameReference>)modder.Module.AssemblyReferences); modder.DependencyMap[OutputModule] = new List<ModuleDefinition>(modder.DependencyMap[modder.Module]); Namespace = Environment.GetEnvironmentVariable("MONOMOD_HOOKGEN_NAMESPACE"); if (string.IsNullOrEmpty(Namespace)) { Namespace = "On"; } NamespaceIL = Environment.GetEnvironmentVariable("MONOMOD_HOOKGEN_NAMESPACE_IL"); if (string.IsNullOrEmpty(NamespaceIL)) { NamespaceIL = "IL"; } HookOrig = Environment.GetEnvironmentVariable("MONOMOD_HOOKGEN_ORIG") == "1"; HookPrivate = Environment.GetEnvironmentVariable("MONOMOD_HOOKGEN_PRIVATE") == "1"; modder.MapDependency(modder.Module, "MonoMod.RuntimeDetour", (string)null, (AssemblyNameReference)null); if (!modder.DependencyCache.TryGetValue("MonoMod.RuntimeDetour", out module_RuntimeDetour)) { throw new FileNotFoundException("MonoMod.RuntimeDetour not found!"); } modder.MapDependency(modder.Module, "MonoMod.Utils", (string)null, (AssemblyNameReference)null); if (!modder.DependencyCache.TryGetValue("MonoMod.Utils", out module_Utils)) { throw new FileNotFoundException("MonoMod.Utils not found!"); } t_MulticastDelegate = OutputModule.ImportReference(modder.FindType("System.MulticastDelegate")); t_IAsyncResult = OutputModule.ImportReference(modder.FindType("System.IAsyncResult")); t_AsyncCallback = OutputModule.ImportReference(modder.FindType("System.AsyncCallback")); t_MethodBase = OutputModule.ImportReference(modder.FindType("System.Reflection.MethodBase")); t_RuntimeMethodHandle = OutputModule.ImportReference(modder.FindType("System.RuntimeMethodHandle")); t_EditorBrowsableState = OutputModule.ImportReference(modder.FindType("System.ComponentModel.EditorBrowsableState")); TypeDefinition type = module_RuntimeDetour.GetType("MonoMod.RuntimeDetour.HookGen.HookEndpointManager"); t_ILManipulator = OutputModule.ImportReference((TypeReference)(object)module_Utils.GetType("MonoMod.Cil.ILContext/Manipulator")); m_Object_ctor = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(modder.FindType("System.Object").Resolve(), "System.Void .ctor()", true)); m_ObsoleteAttribute_ctor = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(modder.FindType("System.ObsoleteAttribute").Resolve(), "System.Void .ctor(System.String,System.Boolean)", true)); m_EditorBrowsableAttribute_ctor = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(modder.FindType("System.ComponentModel.EditorBrowsableAttribute").Resolve(), "System.Void .ctor(System.ComponentModel.EditorBrowsableState)", true)); ModuleDefinition outputModule = OutputModule; MethodReference val = new MethodReference("GetMethodFromHandle", t_MethodBase, t_MethodBase); val.Parameters.Add(new ParameterDefinition(t_RuntimeMethodHandle)); m_GetMethodFromHandle = outputModule.ImportReference(val); m_Add = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(type, "Add", true)); m_Remove = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(type, "Remove", true)); m_Modify = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(type, "Modify", true)); m_Unmodify = OutputModule.ImportReference((MethodReference)(object)Extensions.FindMethod(type, "Unmodify", true)); } public void Generate() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Enumerator<TypeDefinition> enumerator = Modder.Module.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; GenerateFor(current, out var hookType, out var hookILType); if (hookType != null && hookILType != null && !((TypeReference)hookType).IsNested) { OutputModule.Types.Add(hookType); OutputModule.Types.Add(hookILType); } } } finally { ((IDisposable)enumerator).Dispose(); } } public void GenerateFor(TypeDefinition type, out TypeDefinition hookType, out TypeDefinition hookILType) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) hookType = (hookILType = null); if (((TypeReference)type).HasGenericParameters || type.IsRuntimeSpecialName || ((MemberReference)type).Name.StartsWith("<") || (!HookPrivate && type.IsNotPublic)) { return; } Modder.LogVerbose("[HookGen] Generating for type " + ((MemberReference)type).FullName); hookType = new TypeDefinition(((TypeReference)type).IsNested ? null : (Namespace + (string.IsNullOrEmpty(((TypeReference)type).Namespace) ? "" : ("." + ((TypeReference)type).Namespace))), ((MemberReference)type).Name, (TypeAttributes)(((!((TypeReference)type).IsNested) ? 1 : 2) | 0x80 | 0x100 | 0), OutputModule.TypeSystem.Object); hookILType = new TypeDefinition(((TypeReference)type).IsNested ? null : (NamespaceIL + (string.IsNullOrEmpty(((TypeReference)type).Namespace) ? "" : ("." + ((TypeReference)type).Namespace))), ((MemberReference)type).Name, (TypeAttributes)(((!((TypeReference)type).IsNested) ? 1 : 2) | 0x80 | 0x100 | 0), OutputModule.TypeSystem.Object); bool flag = false; Enumerator<MethodDefinition> enumerator = type.Methods.GetEnumerator(); try { while (enumerator.MoveNext()) { MethodDefinition current = enumerator.Current; flag |= GenerateFor(hookType, hookILType, current); } } finally { ((IDisposable)enumerator).Dispose(); } Enumerator<TypeDefinition> enumerator2 = type.NestedTypes.GetEnumerator(); try { while (enumerator2.MoveNext()) { TypeDefinition current2 = enumerator2.Current; GenerateFor(current2, out var hookType2, out var hookILType2); if (hookType2 != null && hookILType2 != null) { flag = true; hookType.NestedTypes.Add(hookType2); hookILType.NestedTypes.Add(hookILType2); } } } finally { ((IDisposable)enumerator2).Dispose(); } if (!flag) { hookType = (hookILType = null); } } public bool GenerateFor(TypeDefinition hookType, TypeDefinition hookILType, MethodDefinition method) { //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Expected O, but got Unknown //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Expected O, but got Unknown //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Expected O, but got Unknown //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Expected O, but got Unknown //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Expected O, but got Unknown //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Expected O, but got Unknown //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Expected O, but got Unknown //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Expected O, but got Unknown //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Expected O, but got Unknown //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Expected O, but got Unknown //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Expected O, but got Unknown //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Expected O, but got Unknown //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Expected O, but got Unknown //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Expected O, but got Unknown //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Expected O, but got Unknown //IL_061e: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Expected O, but got Unknown //IL_0635: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Expected O, but got Unknown //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Expected O, but got Unknown if (((MethodReference)method).HasGenericParameters || method.IsAbstract || (method.IsSpecialName && !method.IsConstructor)) { return false; } if (!HookOrig && ((MemberReference)method).Name.StartsWith("orig_")) { return false; } if (!HookPrivate && method.IsPrivate) { return false; } string name = GetFriendlyName((MethodReference)(object)method); bool flag = true; if (((MethodReference)method).Parameters.Count == 0) { flag = false; } IEnumerable<MethodDefinition> source = null; if (flag) { source = ((IEnumerable<MethodDefinition>)method.DeclaringType.Methods).Where((MethodDefinition other) => !((MethodReference)other).HasGenericParameters && GetFriendlyName((MethodReference)(object)other) == name && other != method); if (source.Count() == 0) { flag = false; } } if (flag) { StringBuilder stringBuilder = new StringBuilder(); for (int parami = 0; parami < ((MethodReference)method).Parameters.Count; parami++) { ParameterDefinition param = ((MethodReference)method).Parameters[parami]; if (!TypeNameMap.TryGetValue(((MemberReference)((ParameterReference)param).ParameterType).FullName, out var typeName)) { typeName = GetFriendlyName(((ParameterReference)param).ParameterType, full: false); } if (source.Any(delegate(MethodDefinition other) { ParameterDefinition val11 = ((IEnumerable<ParameterDefinition>)((MethodReference)other).Parameters).ElementAtOrDefault(parami); return val11 != null && GetFriendlyName(((ParameterReference)val11).ParameterType, full: false) == typeName && ((ParameterReference)val11).ParameterType.Namespace != ((ParameterReference)param).ParameterType.Namespace; })) { typeName = GetFriendlyName(((ParameterReference)param).ParameterType, full: true); } stringBuilder.Append("_"); stringBuilder.Append(typeName.Replace(".", "").Replace("`", "")); } name += stringBuilder.ToString(); } if (Extensions.FindEvent(hookType, name) != null) { int num = 1; string text; while (Extensions.FindEvent(hookType, text = name + "_" + num) != null) { num++; } name = text; } TypeDefinition val = GenerateDelegateFor(method); ((MemberReference)val).Name = "orig_" + name; val.CustomAttributes.Add(GenerateEditorBrowsable(EditorBrowsableState.Never)); hookType.NestedTypes.Add(val); TypeDefinition val2 = GenerateDelegateFor(method); ((MemberReference)val2).Name = "hook_" + name; ((MethodReference)Extensions.FindMethod(val2, "Invoke", true)).Parameters.Insert(0, new ParameterDefinition("orig", (ParameterAttributes)0, (TypeReference)(object)val)); ((MethodReference)Extensions.FindMethod(val2, "BeginInvoke", true)).Parameters.Insert(0, new ParameterDefinition("orig", (ParameterAttributes)0, (TypeReference)(object)val)); val2.CustomAttributes.Add(GenerateEditorBrowsable(EditorBrowsableState.Never)); hookType.NestedTypes.Add(val2); MethodReference val3 = OutputModule.ImportReference((MethodReference)(object)method); MethodDefinition val4 = new MethodDefinition("add_" + name, (MethodAttributes)2198, OutputModule.TypeSystem.Void); ((MethodReference)val4).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, (TypeReference)(object)val2)); val4.Body = new MethodBody(val4); ILProcessor iLProcessor = val4.Body.GetILProcessor(); iLProcessor.Emit(OpCodes.Ldtoken, val3); iLProcessor.Emit(OpCodes.Call, m_GetMethodFromHandle); iLProcessor.Emit(OpCodes.Ldarg_0); GenericInstanceMethod val5 = new GenericInstanceMethod(m_Add); val5.GenericArguments.Add((TypeReference)(object)val2); iLProcessor.Emit(OpCodes.Call, (MethodReference)(object)val5); iLProcessor.Emit(OpCodes.Ret); hookType.Methods.Add(val4); MethodDefinition val6 = new MethodDefinition("remove_" + name, (MethodAttributes)2198, OutputModule.TypeSystem.Void); ((MethodReference)val6).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, (TypeReference)(object)val2)); val6.Body = new MethodBody(val6); ILProcessor iLProcessor2 = val6.Body.GetILProcessor(); iLProcessor2.Emit(OpCodes.Ldtoken, val3); iLProcessor2.Emit(OpCodes.Call, m_GetMethodFromHandle); iLProcessor2.Emit(OpCodes.Ldarg_0); val5 = new GenericInstanceMethod(m_Remove); val5.GenericArguments.Add((TypeReference)(object)val2); iLProcessor2.Emit(OpCodes.Call, (MethodReference)(object)val5); iLProcessor2.Emit(OpCodes.Ret); hookType.Methods.Add(val6); EventDefinition val7 = new EventDefinition(name, (EventAttributes)0, (TypeReference)(object)val2) { AddMethod = val4, RemoveMethod = val6 }; hookType.Events.Add(val7); MethodDefinition val8 = new MethodDefinition("add_" + name, (MethodAttributes)2198, OutputModule.TypeSystem.Void); ((MethodReference)val8).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, t_ILManipulator)); val8.Body = new MethodBody(val8); ILProcessor iLProcessor3 = val8.Body.GetILProcessor(); iLProcessor3.Emit(OpCodes.Ldtoken, val3); iLProcessor3.Emit(OpCodes.Call, m_GetMethodFromHandle); iLProcessor3.Emit(OpCodes.Ldarg_0); val5 = new GenericInstanceMethod(m_Modify); val5.GenericArguments.Add((TypeReference)(object)val2); iLProcessor3.Emit(OpCodes.Call, (MethodReference)(object)val5); iLProcessor3.Emit(OpCodes.Ret); hookILType.Methods.Add(val8); MethodDefinition val9 = new MethodDefinition("remove_" + name, (MethodAttributes)2198, OutputModule.TypeSystem.Void); ((MethodReference)val9).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, t_ILManipulator)); val9.Body = new MethodBody(val9); ILProcessor iLProcessor4 = val9.Body.GetILProcessor(); iLProcessor4.Emit(OpCodes.Ldtoken, val3); iLProcessor4.Emit(OpCodes.Call, m_GetMethodFromHandle); iLProcessor4.Emit(OpCodes.Ldarg_0); val5 = new GenericInstanceMethod(m_Unmodify); val5.GenericArguments.Add((TypeReference)(object)val2); iLProcessor4.Emit(OpCodes.Call, (MethodReference)(object)val5); iLProcessor4.Emit(OpCodes.Ret); hookILType.Methods.Add(val9); EventDefinition val10 = new EventDefinition(name, (EventAttributes)0, t_ILManipulator) { AddMethod = val8, RemoveMethod = val9 }; hookILType.Events.Add(val10); return true; } public TypeDefinition GenerateDelegateFor(MethodDefinition method) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Expected O, but got Unknown //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Expected O, but got Unknown //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Expected O, but got Unknown //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Expected O, but got Unknown string name = GetFriendlyName((MethodReference)(object)method); int num = ((IEnumerable<MethodDefinition>)method.DeclaringType.Methods).Where((MethodDefinition other) => !((MethodReference)other).HasGenericParameters && GetFriendlyName((MethodReference)(object)other) == name).ToList().IndexOf(method); if (num != 0) { string suffix = num.ToString(); do { name = name + "_" + suffix; } while (((IEnumerable<MethodDefinition>)method.DeclaringType.Methods).Any((MethodDefinition other) => !((MethodReference)other).HasGenericParameters && GetFriendlyName((MethodReference)(object)other) == name + suffix)); } name = "d_" + name; TypeDefinition val = new TypeDefinition((string)null, (string)null, (TypeAttributes)258, t_MulticastDelegate); MethodDefinition val2 = new MethodDefinition(".ctor", (MethodAttributes)6278, OutputModule.TypeSystem.Void) { ImplAttributes = (MethodImplAttributes)3, HasThis = true }; ((MethodReference)val2).Parameters.Add(new ParameterDefinition(OutputModule.TypeSystem.Object)); ((MethodReference)val2).Parameters.Add(new ParameterDefinition(OutputModule.TypeSystem.IntPtr)); val2.Body = new MethodBody(val2); val.Methods.Add(val2); MethodDefinition val3 = new MethodDefinition("Invoke", (MethodAttributes)454, ImportVisible(((MethodReference)method).ReturnType)) { ImplAttributes = (MethodImplAttributes)3, HasThis = true }; if (!method.IsStatic) { TypeReference val4 = ImportVisible((TypeReference)(object)method.DeclaringType); if (((TypeReference)method.DeclaringType).IsValueType) { val4 = (TypeReference)new ByReferenceType(val4); } ((MethodReference)val3).Parameters.Add(new ParameterDefinition("self", (ParameterAttributes)0, val4)); } Enumerator<ParameterDefinition> enumerator = ((MethodReference)method).Parameters.GetEnumerator(); try { while (enumerator.MoveNext()) { ParameterDefinition current = enumerator.Current; ((MethodReference)val3).Parameters.Add(new ParameterDefinition(((ParameterReference)current).Name, (ParameterAttributes)(current.Attributes & 0xFFEF & 0xEFFF), ImportVisible(((ParameterReference)current).ParameterType))); } } finally { ((IDisposable)enumerator).Dispose(); } val3.Body = new MethodBody(val3); val.Methods.Add(val3); MethodDefinition val5 = new MethodDefinition("BeginInvoke", (MethodAttributes)454, t_IAsyncResult) { ImplAttributes = (MethodImplAttributes)3, HasThis = true }; enumerator = ((MethodReference)val3).Parameters.GetEnumerator(); try { while (enumerator.MoveNext()) { ParameterDefinition current2 = enumerator.Current; ((MethodReference)val5).Parameters.Add(new ParameterDefinition(((ParameterReference)current2).Name, current2.Attributes, ((ParameterReference)current2).ParameterType)); } } finally { ((IDisposable)enumerator).Dispose(); } ((MethodReference)val5).Parameters.Add(new ParameterDefinition("callback", (ParameterAttributes)0, t_AsyncCallback)); ((MethodReference)val5).Parameters.Add(new ParameterDefinition((string)null, (ParameterAttributes)0, OutputModule.TypeSystem.Object)); val5.Body = new MethodBody(val5); val.Methods.Add(val5); MethodDefinition val6 = new MethodDefinition("EndInvoke", (MethodAttributes)454, OutputModule.TypeSystem.Object) { ImplAttributes = (MethodImplAttributes)3, HasThis = true }; ((MethodReference)val6).Parameters.Add(new ParameterDefinition("result", (ParameterAttributes)0, t_IAsyncResult)); val6.Body = new MethodBody(val6); val.Methods.Add(val6); return val; } private string GetFriendlyName(MethodReference method) { string text = ((MemberReference)method).Name; if (text.StartsWith(".")) { text = text.Substring(1); } return text.Replace('.', '_'); } private string GetFriendlyName(TypeReference type, bool full) { if (type is TypeSpecification) { StringBuilder stringBuilder = new StringBuilder(); BuildFriendlyName(stringBuilder, type, full); return stringBuilder.ToString(); } if (!full) { return ((MemberReference)type).Name; } return ((MemberReference)type).FullName; } private void BuildFriendlyName(StringBuilder builder, TypeReference type, bool full) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!(type is TypeSpecification)) { builder.Append((full ? ((MemberReference)type).FullName : ((MemberReference)type).Name).Replace("_", "")); return; } if (type.IsByReference) { builder.Append("ref"); } else if (type.IsPointer) { builder.Append("ptr"); } BuildFriendlyName(builder, ((TypeSpecification)type).ElementType, full); if (type.IsArray) { builder.Append("Array"); } } private bool IsPublic(TypeDefinition typeDef) { if (typeDef != null && (typeDef.IsNestedPublic || typeDef.IsPublic)) { return !typeDef.IsNotPublic; } return false; } private bool HasPublicArgs(GenericInstanceType typeGen) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Enumerator<TypeReference> enumerator = typeGen.GenericArguments.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeReference current = enumerator.Current; if (current.IsGenericParameter) { return false; } GenericInstanceType val = (GenericInstanceType)(object)((current is GenericInstanceType) ? current : null); if (val != null && !HasPublicArgs(val)) { return false; } if (!IsPublic(Extensions.SafeResolve(current))) { return false; } } } finally { ((IDisposable)enumerator).Dispose(); } return true; } private TypeReference ImportVisible(TypeReference typeRef) { for (TypeDefinition val = ((typeRef != null) ? Extensions.SafeResolve(typeRef) : null); val != null; val = ((typeRef != null) ? Extensions.SafeResolve(typeRef) : null)) { GenericInstanceType val2 = (GenericInstanceType)(object)((typeRef is GenericInstanceType) ? typeRef : null); if (val2 == null || HasPublicArgs(val2)) { TypeDefinition val3 = val; while (true) { if (val3 != null) { if (IsPublic(val3) && (val3 == val || !((TypeReference)val3).HasGenericParameters)) { val3 = val3.DeclaringType; continue; } if (!val.IsEnum) { break; } typeRef = ((FieldReference)Extensions.FindField(val, "value__")).FieldType; } try { return OutputModule.ImportReference(typeRef); } catch { return OutputModule.TypeSystem.Object; } } } typeRef = val.BaseType; } return OutputModule.TypeSystem.Object; } private CustomAttribute GenerateObsolete(string message, bool error) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown CustomAttribute val = new CustomAttribute(m_ObsoleteAttribute_ctor); val.ConstructorArguments.Add(new CustomAttributeArgument(OutputModule.TypeSystem.String, (object)message)); val.ConstructorArguments.Add(new CustomAttributeArgument(OutputModule.TypeSystem.Boolean, (object)error)); return val; } private CustomAttribute GenerateEditorBrowsable(EditorBrowsableState state) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown CustomAttribute val = new CustomAttribute(m_EditorBrowsableAttribute_ctor); val.ConstructorArguments.Add(new CustomAttributeArgument(t_EditorBrowsableState, (object)state)); return val; } } internal class Program { private static void Main(string[] args) { //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown Console.WriteLine("MonoMod.RuntimeDetour.HookGen " + typeof(Program).Assembly.GetName().Version); Console.WriteLine("using MonoMod " + typeof(MonoModder).Assembly.GetName().Version); Console.WriteLine("using MonoMod.RuntimeDetour " + typeof(Detour).Assembly.GetName().Version); if (args.Length == 0) { Console.WriteLine("No valid arguments (assembly path) passed."); if (Debugger.IsAttached) { Console.ReadKey(); } return; } int num = 0; for (int i = 0; i < args.Length; i++) { if (args[i] == "--namespace" && i + 2 < args.Length) { i++; Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_NAMESPACE", args[i]); continue; } if (args[i] == "--namespace-il" && i + 2 < args.Length) { i++; Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_NAMESPACE_IL", args[i]); continue; } if (args[i] == "--orig") { Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_ORIG", "1"); continue; } if (args[i] == "--private") { Environment.SetEnvironmentVariable("MONOMOD_HOOKGEN_PRIVATE", "1"); continue; } num = i; break; } if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW"))) { Environment.SetEnvironmentVariable("MONOMOD_DEPENDENCY_MISSING_THROW", "0"); } if (num >= args.Length) { Console.WriteLine("No assembly path passed."); if (Debugger.IsAttached) { Console.ReadKey(); } return; } string text = args[num]; string text2 = ((args.Length != 1 && num != args.Length - 1) ? args[^1] : null); text2 = text2 ?? Path.Combine(Path.GetDirectoryName(text), "MMHOOK_" + Path.ChangeExtension(Path.GetFileName(text), "dll")); MonoModder val = new MonoModder { InputPath = text, OutputPath = text2, ReadingMode = (ReadingMode)2 }; try { val.Read(); val.MapDependencies(); if (File.Exists(text2)) { val.Log("[HookGen] Clearing " + text2); File.Delete(text2); } val.Log("[HookGen] Starting HookGenerator"); HookGenerator hookGenerator = new HookGenerator(val, Path.GetFileName(text2)); ModuleDefinition outputModule = hookGenerator.OutputModule; try { hookGenerator.Generate(); outputModule.Write(text2); } finally { ((IDisposable)outputModule)?.Dispose(); } val.Log("[HookGen] Done."); } finally { ((IDisposable)val)?.Dispose(); } if (Debugger.IsAttached) { Console.ReadKey(); } } } }
plugins/BuyableShotgun.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.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; 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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("BuyableShotgun")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyCopyright("Copyright © 2023 MegaPiggy")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BuyableShotgun")] [assembly: AssemblyTitle("BuyableShotgun")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 BuyableShotgun { [BepInPlugin("MegaPiggy.BuyableShotgun", "BuyableShotgun", "1.0.0")] public class BuyableShotgun : BaseUnityPlugin { private const string modGUID = "MegaPiggy.BuyableShotgun"; private const string modName = "BuyableShotgun"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("MegaPiggy.BuyableShotgun"); private static BuyableShotgun Instance; public int ShotgunPrice; public bool added; private static ManualLogSource LoggerInstance => ((BaseUnityPlugin)Instance).Logger; public List<Item> AllItems => Resources.FindObjectsOfTypeAll<Item>().Concat(Object.FindObjectsByType<Item>((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList(); public Item Shotgun => ((IEnumerable<Item>)AllItems).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "Shotgun")); private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } harmony.PatchAll(); ShotgunPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Prices", "ShotgunPrice", 700, "Credits needed to buy shotgun").Value; SceneManager.sceneLoaded += OnSceneLoaded; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BuyableShotgun is loaded with version 1.0.0!"); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (!added && ((Scene)(ref scene)).name == "MainMenu") { added = true; Items.RegisterShopItem(Shotgun, ShotgunPrice); } } } }
plugins/ChillaxMods.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; 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 GameNetcodeStuff; using HarmonyLib; using LethalLib; using LethalLib.Extras; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using Unity.Netcode.Components; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ChillaxMods")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Chillax Mods")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ChillaxMods")] [assembly: AssemblyTitle("ChillaxMods")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] internal class <Module> { static <Module>() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>(); } } 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 ChillaxMods { public static class PluginInfo { public const string PLUGIN_GUID = "ChillaxMods"; public const string PLUGIN_NAME = "ChillaxMods"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Chillax.Bastard.BogBog { public class Boink : NoisemakerProp { public override void ItemActivate(bool used, bool buttonDown = true) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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) if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null)) { PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy; Vector3 val = -((Component)this).transform.forward + Vector3.up; playerHeldBy.externalForces = ((Vector3)(ref val)).normalized * 500f; ChillaxModPlugin.logger.LogInfo((object)"[CHILLAX] ACTIVATE BOINK!"); ((NoisemakerProp)this).ItemActivate(used, buttonDown); } } protected override void __initializeVariables() { ((NoisemakerProp)this).__initializeVariables(); } protected internal override string __getTypeName() { return "Boink"; } } [BepInPlugin("chillax.bastard.mod", "Chillax Mods", "0.5.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ChillaxModPlugin : BaseUnityPlugin { public static ManualLogSource logger; public const string PluginGuid = "chillax.bastard.mod"; public const string PluginName = "Chillax Mods"; public const string PluginVersion = "0.5.2"; public static readonly Harmony harmony = new Harmony("chillax.bastard.mod"); public static ConfigFile config; public void Awake() { logger = ((BaseUnityPlugin)this).Logger; config = ((BaseUnityPlugin)this).Config; Config.Load(); Content.Load(); harmony.PatchAll(typeof(ChillaxModPlugin)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CHILLAX Plugin Loaded"); } } public class Config { public static ConfigEntry<int> boinkSpawnChance; public static ConfigEntry<int> cupNoodleSpawnChance; public static ConfigEntry<int> freddySpawnChance; public static ConfigEntry<int> nokiaSpawnChance; public static ConfigEntry<int> moaiSpawnChance; public static ConfigEntry<int> froggySpawnChance; public static ConfigEntry<int> eeveeSpawnChance; public static ConfigEntry<int> deathNoteSpawnChance; public static ConfigEntry<int> unoReverseSpawnChance; public static ConfigEntry<bool> canUseDeathNote; public static void Load() { boinkSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Boink", 30, "How much does this Item spawn, higher = more common"); cupNoodleSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "CupNoodle", 40, "How much does this Item spawn, higher = more common"); freddySpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Freddy", 15, "How much does this Item spawn, higher = more common"); nokiaSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Nokia", 30, "How much does this Item spawn, higher = more common"); moaiSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Moai", 20, "How much does this Item spawn, higher = more common"); froggySpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Froggy", 30, "How much does this Item spawn, higher = more common"); eeveeSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "Eevee", 30, "How much does this Item spawn, higher = more common"); deathNoteSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "DeathNote", 20, "How much does this Item spawn, higher = more common"); canUseDeathNote = ChillaxModPlugin.config.Bind<bool>("Death Note", "DeathNoteActive", true, "Can the Death Note be used, turn this off to avoid griefing"); unoReverseSpawnChance = ChillaxModPlugin.config.Bind<int>("Scrap", "UnoReverse", 20, "How much does this Item spawn, higher = more common"); } } public class Content { public class CustomItem { public string name = ""; public string itemPath = ""; public string infoPath = ""; public Action<Item> itemAction = delegate { }; public bool enabled = true; public CustomItem(string name, string itemPath, string infoPath, Action<Item> action = null) { this.name = name; this.itemPath = itemPath; this.infoPath = infoPath; if (action != null) { itemAction = action; } } public static CustomItem Add(string name, string itemPath, string infoPath = null, Action<Item> action = null) { return new CustomItem(name, itemPath, infoPath, action); } } public class CustomUnlockable { public string name = ""; public string unlockablePath = ""; public string infoPath = ""; public Action<UnlockableItem> unlockableAction = delegate { }; public bool enabled = true; public int unlockCost = -1; public CustomUnlockable(string name, string unlockablePath, string infoPath, Action<UnlockableItem> action = null, int unlockCost = -1) { this.name = name; this.unlockablePath = unlockablePath; this.infoPath = infoPath; if (action != null) { unlockableAction = action; } this.unlockCost = unlockCost; } public static CustomUnlockable Add(string name, string unlockablePath, string infoPath = null, Action<UnlockableItem> action = null, int unlockCost = -1, bool enabled = true) { return new CustomUnlockable(name, unlockablePath, infoPath, action, unlockCost) { enabled = enabled }; } } public class CustomShopItem : CustomItem { public int itemPrice; public CustomShopItem(string name, string itemPath, string infoPath = null, int itemPrice = 0, Action<Item> action = null) : base(name, itemPath, infoPath, action) { this.itemPrice = itemPrice; } public static CustomShopItem Add(string name, string itemPath, string infoPath = null, int itemPrice = 0, Action<Item> action = null, bool enabled = true) { CustomShopItem customShopItem = new CustomShopItem(name, itemPath, infoPath, itemPrice, action); customShopItem.enabled = enabled; return customShopItem; } } public class CustomScrap : CustomItem { public LevelTypes levelType = (LevelTypes)510; public int rarity; public CustomScrap(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null) : base(name, itemPath, null, action) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) this.levelType = levelType; this.rarity = rarity; } public static CustomScrap Add(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return new CustomScrap(name, itemPath, levelType, rarity, action); } } public class CustomEnemy { public string name; public string enemyPath; public int rarity; public LevelTypes levelFlags; public SpawnType spawnType; public string infoKeyword; public string infoNode; public bool enabled = true; public CustomEnemy(string name, string enemyPath, int rarity, LevelTypes levelFlags, SpawnType spawnType, string infoKeyword, string infoNode) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) this.name = name; this.enemyPath = enemyPath; this.rarity = rarity; this.levelFlags = levelFlags; this.spawnType = spawnType; this.infoKeyword = infoKeyword; this.infoNode = infoNode; } public static CustomEnemy Add(string name, string enemyPath, int rarity, LevelTypes levelFlags, SpawnType spawnType, string infoKeyword, string infoNode, bool enabled = true) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return new CustomEnemy(name, enemyPath, rarity, levelFlags, spawnType, infoKeyword, infoNode) { enabled = enabled }; } } public class CustomMapObject { public string name; public string objectPath; public LevelTypes levelFlags; public Func<SelectableLevel, AnimationCurve> spawnRateFunction; public bool enabled = true; public CustomMapObject(string name, string objectPath, LevelTypes levelFlags, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, bool enabled = false) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) this.name = name; this.objectPath = objectPath; this.levelFlags = levelFlags; this.spawnRateFunction = spawnRateFunction; this.enabled = enabled; } public static CustomMapObject Add(string name, string objectPath, LevelTypes levelFlags, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, bool enabled = false) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return new CustomMapObject(name, objectPath, levelFlags, spawnRateFunction, enabled); } } public static AssetBundle MainAssets; public static Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>(); public static List<CustomUnlockable> customUnlockables; public static List<CustomItem> customItems; public static List<CustomEnemy> customEnemies; public static List<CustomMapObject> customMapObjects; public static GameObject ConfigManagerPrefab; public static void TryLoadAssets() { if ((Object)(object)MainAssets == (Object)null) { MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "chillaxBundle")); Plugin.logger.LogInfo((object)"Loaded asset bundle"); } } public static void Load() { //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) TryLoadAssets(); customItems = new List<CustomItem> { CustomScrap.Add("Boink", "Assets/Chillax/ChillaxMods/Boink/Boink.asset", (LevelTypes)510, Config.boinkSpawnChance.Value), CustomScrap.Add("MamaMooSup", "Assets/Chillax/ChillaxMods/Cup Noodle/Cup Noodle.asset", (LevelTypes)510, Config.cupNoodleSpawnChance.Value), CustomScrap.Add("Freddy", "Assets/Chillax/ChillaxMods/FreddyFastBear/Freddy.asset", (LevelTypes)510, Config.freddySpawnChance.Value), CustomScrap.Add("Nokia", "Assets/Chillax/ChillaxMods/Nokia/Nokia.asset", (LevelTypes)510, Config.nokiaSpawnChance.Value), CustomScrap.Add("Moai", "Assets/Chillax/ChillaxMods/Moai/Moai.asset", (LevelTypes)510, Config.moaiSpawnChance.Value), CustomScrap.Add("Froggy", "Assets/Chillax/ChillaxMods/Froggy Chair/Froggy Chair.asset", (LevelTypes)510, Config.froggySpawnChance.Value), CustomScrap.Add("Eevee", "Assets/Chillax/ChillaxMods/Eevee Plush/Eevee.asset", (LevelTypes)510, Config.eeveeSpawnChance.Value), CustomScrap.Add("DeathNote", "Assets/Chillax/ChillaxMods/DeathNote/DeathNote.asset", (LevelTypes)510, Config.deathNoteSpawnChance.Value), CustomScrap.Add("UnoReverse", "Assets/Chillax/ChillaxMods/UnoReverse/UnoReverse.asset", (LevelTypes)510, Config.unoReverseSpawnChance.Value) }; customEnemies = new List<CustomEnemy>(); customUnlockables = new List<CustomUnlockable>(); customMapObjects = new List<CustomMapObject>(); foreach (CustomItem customItem in customItems) { if (customItem.enabled) { Item val = MainAssets.LoadAsset<Item>(customItem.itemPath); if ((Object)(object)val.spawnPrefab.GetComponent<NetworkTransform>() == (Object)null) { val.spawnPrefab.AddComponent<NetworkTransform>(); } Prefabs.Add(customItem.name, val.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); customItem.itemAction(val); if (customItem is CustomShopItem) { TerminalNode val2 = MainAssets.LoadAsset<TerminalNode>(customItem.infoPath); Plugin.logger.LogInfo((object)$"Registering shop item {customItem.name} with price {((CustomShopItem)customItem).itemPrice}"); Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val2, ((CustomShopItem)customItem).itemPrice); } else if (customItem is CustomScrap customScrap) { ChillaxModPlugin.logger.LogInfo((object)$"[CHILLAX] Registering... {val.itemName} at rarity {customScrap.rarity}"); Items.RegisterScrap(val, customScrap.rarity, customScrap.levelType); } } } foreach (CustomUnlockable customUnlockable in customUnlockables) { if (customUnlockable.enabled) { UnlockableItem unlockable = MainAssets.LoadAsset<UnlockableItemDef>(customUnlockable.unlockablePath).unlockable; if ((Object)(object)unlockable.prefabObject != (Object)null) { NetworkPrefabs.RegisterNetworkPrefab(unlockable.prefabObject); } Prefabs.Add(customUnlockable.name, unlockable.prefabObject); TerminalNode val3 = null; if (customUnlockable.infoPath != null) { val3 = MainAssets.LoadAsset<TerminalNode>(customUnlockable.infoPath); } Unlockables.RegisterUnlockable(unlockable, (StoreType)2, (TerminalNode)null, (TerminalNode)null, val3, customUnlockable.unlockCost); } } foreach (CustomEnemy customEnemy in customEnemies) { if (customEnemy.enabled) { EnemyType val4 = MainAssets.LoadAsset<EnemyType>(customEnemy.enemyPath); TerminalNode val5 = MainAssets.LoadAsset<TerminalNode>(customEnemy.infoNode); TerminalKeyword val6 = null; if (customEnemy.infoKeyword != null) { val6 = MainAssets.LoadAsset<TerminalKeyword>(customEnemy.infoKeyword); } NetworkPrefabs.RegisterNetworkPrefab(val4.enemyPrefab); Prefabs.Add(customEnemy.name, val4.enemyPrefab); Enemies.RegisterEnemy(val4, customEnemy.rarity, customEnemy.levelFlags, customEnemy.spawnType, val5, val6); } } foreach (CustomMapObject customMapObject in customMapObjects) { if (customMapObject.enabled) { SpawnableMapObjectDef val7 = MainAssets.LoadAsset<SpawnableMapObjectDef>(customMapObject.objectPath); NetworkPrefabs.RegisterNetworkPrefab(val7.spawnableMapObject.prefabToSpawn); Prefabs.Add(customMapObject.name, val7.spawnableMapObject.prefabToSpawn); MapObjects.RegisterMapObject(val7, customMapObject.levelFlags, customMapObject.spawnRateFunction); } } Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } Plugin.logger.LogInfo((object)"[CHILLAX] Custom content loaded!"); } } public class DeathNote : NoisemakerProp { private NetworkVariable<bool> canUseDeathNote = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); [SerializeField] private AudioClip killSfx; [SerializeField] private GameObject canvasPrefab; private float _currentCooldown; [SerializeField] private float checkRate; [SerializeField] private Renderer deathNoteRenderer; [SerializeField] private Material[] materials; [SerializeField] private string[] textNodes; [SerializeField] private Sprite[] icons; [SerializeField] private ScanNodeProperties scanNodeProperties; private DeathNoteCanvas _temp; public List<PlayerControllerB> playerList; public List<EnemyAI> enemyList; private bool _opened; public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); canUseDeathNote = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); playerList = new List<PlayerControllerB>(); enemyList = new List<EnemyAI>(); Item itemProperties = Object.Instantiate<Item>(((GrabbableObject)this).itemProperties); ((GrabbableObject)this).itemProperties = itemProperties; UpdateList(); _opened = false; ((MonoBehaviour)this).InvokeRepeating("ProcessCooldown", checkRate, checkRate); if (((NetworkBehaviour)this).IsHost) { canUseDeathNote.Value = Config.canUseDeathNote.Value; UpdateVisuals(0); UpdateVisualsClientRpc(0); } } [ClientRpc] private void UpdateVisualsClientRpc(int index) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(531245751u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, index); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 531245751u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { UpdateVisuals(index); } } } private void UpdateVisuals(int index) { if ((Object)(object)deathNoteRenderer.material != (Object)(object)materials[index]) { deathNoteRenderer.material = materials[index]; } scanNodeProperties.headerText = textNodes[index]; ((GrabbableObject)this).itemProperties.itemName = textNodes[index]; ((GrabbableObject)this).itemProperties.itemIcon = icons[index]; } [ServerRpc(RequireOwnership = false)] private void StartCooldownServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(246655775u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 246655775u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { Random random = new Random(); StartCooldownClientRpc(_currentCooldown = random.Next(600, 1800)); } } } [ClientRpc] private void StartCooldownClientRpc(float cooldown) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(316831956u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref cooldown, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 316831956u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { _currentCooldown = cooldown; } } } private void ProcessCooldown() { if (_currentCooldown > 0f) { _currentCooldown -= checkRate; UpdateVisuals(1); } else { UpdateVisuals(0); } } private void UpdateList() { playerList = Object.FindObjectsOfType<PlayerControllerB>().ToList(); enemyList = Object.FindObjectsOfType<EnemyAI>().ToList(); } private void OnDisable() { if ((Object)(object)_temp != (Object)null) { _temp.Close(); } } public override void DiscardItem() { ((GrabbableObject)this).DiscardItem(); if ((Object)(object)_temp != (Object)null) { _temp.Close(); } } public override void PocketItem() { ((GrabbableObject)this).PocketItem(); if ((Object)(object)_temp != (Object)null) { _temp.Close(); } } public override void ItemActivate(bool used, bool buttonDown = true) { if (canUseDeathNote.Value && !_opened && !(_currentCooldown > 0f)) { ((NoisemakerProp)this).ItemActivate(used, buttonDown); if (((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner) { UpdateList(); _temp = Object.Instantiate<GameObject>(canvasPrefab, ((Component)this).transform).GetComponent<DeathNoteCanvas>(); _temp.Initialize(this); _opened = true; Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; DeathNoteCanvas temp = _temp; temp.onExit = (Action)Delegate.Combine(temp.onExit, new Action(OnExit)); } } } private void OnExit() { Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; _opened = false; } public void ActivateDeathNote(GameObject objectToKill) { OnExit(); if (Object.op_Implicit((Object)(object)objectToKill.GetComponent<PlayerControllerB>())) { KillPlayer(objectToKill.GetComponent<PlayerControllerB>()); } if (Object.op_Implicit((Object)(object)objectToKill.GetComponent<EnemyAI>())) { KillEnemy(objectToKill.GetComponent<EnemyAI>()); } StartCooldownServerRpc(); } private void KillPlayer(PlayerControllerB controller) { if (!((Object)(object)controller == (Object)null)) { Debug.Log((object)("[CHILLAX] [DEATH NOTE] killing off player: " + controller.playerUsername)); DeathNoteServerRpc(controller.playerClientId, ((NetworkBehaviour)controller).OwnerClientId); } } private void KillEnemy(EnemyAI enemy) { if (!((Object)(object)enemy == (Object)null)) { Debug.Log((object)("[CHILLAX] [DEATH NOTE] killing off enemy: " + enemy.enemyType.enemyName)); enemy.KillEnemyServerRpc(false); } } [ServerRpc(RequireOwnership = false)] private void DeathNoteServerRpc(ulong playerID, ulong clientID) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2937588739u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerID); BytePacker.WriteValueBitPacked(val2, clientID); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2937588739u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerID].GetComponent<PlayerControllerB>(); Debug.Log((object)("[DEATH NOTE] Receive Server RPC, player to kill: " + component.playerUsername)); ClientRpcParams val3 = default(ClientRpcParams); val3.Send = new ClientRpcSendParams { TargetClientIds = new ulong[1] { clientID } }; ClientRpcParams clientRpcParams = val3; DeathNoteClientRpc(component.playerClientId, clientRpcParams); } } } [ClientRpc] private void DeathNoteClientRpc(ulong playerID, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2281964886u, clientRpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, playerID); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2281964886u, clientRpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerID].GetComponent<PlayerControllerB>(); Debug.Log((object)("[DEATH NOTE] Receive Client RPC, player to kill: " + component.playerUsername)); Debug.Log((object)("[DEATH NOTE] Killing: " + component.playerUsername)); ((MonoBehaviour)this).StartCoroutine(KilLDelay(component)); } } } private IEnumerator KilLDelay(PlayerControllerB controller) { if (((NetworkBehaviour)controller).IsOwner) { AudioSource tempSource = ((Component)controller).gameObject.AddComponent<AudioSource>(); tempSource.PlayOneShot(killSfx); Object.Destroy((Object)(object)tempSource, 3f); } yield return (object)new WaitForSeconds(3f); controller.KillPlayer(Vector3.up * 10f, true, (CauseOfDeath)0, 0); } protected override void __initializeVariables() { if (canUseDeathNote == null) { throw new Exception("DeathNote.canUseDeathNote cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)canUseDeathNote).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)canUseDeathNote, "canUseDeathNote"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)canUseDeathNote); ((NoisemakerProp)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_DeathNote() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(531245751u, new RpcReceiveHandler(__rpc_handler_531245751)); NetworkManager.__rpc_func_table.Add(246655775u, new RpcReceiveHandler(__rpc_handler_246655775)); NetworkManager.__rpc_func_table.Add(316831956u, new RpcReceiveHandler(__rpc_handler_316831956)); NetworkManager.__rpc_func_table.Add(2937588739u, new RpcReceiveHandler(__rpc_handler_2937588739)); NetworkManager.__rpc_func_table.Add(2281964886u, new RpcReceiveHandler(__rpc_handler_2281964886)); } private static void __rpc_handler_531245751(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int index = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref index); target.__rpc_exec_stage = (__RpcExecStage)2; ((DeathNote)(object)target).UpdateVisualsClientRpc(index); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_246655775(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((DeathNote)(object)target).StartCooldownServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_316831956(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { float cooldown = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref cooldown, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)2; ((DeathNote)(object)target).StartCooldownClientRpc(cooldown); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2937588739(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong playerID = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerID); ulong clientID = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref clientID); target.__rpc_exec_stage = (__RpcExecStage)1; ((DeathNote)(object)target).DeathNoteServerRpc(playerID, clientID); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2281964886(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong playerID = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerID); ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)2; ((DeathNote)(object)target).DeathNoteClientRpc(playerID, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "DeathNote"; } } public class DeathNoteCanvas : MonoBehaviour { [SerializeField] private Button closeButton; [SerializeField] private GameObject namesPrefab; [SerializeField] private Transform contentContainer; private string _chosenName; private DeathNote _deathNote; public Action onExit; public void Initialize(DeathNote deathNote) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown foreach (Transform item in contentContainer) { Transform val = item; Object.Destroy((Object)(object)((Component)val).gameObject); } ((UnityEvent)closeButton.onClick).AddListener(new UnityAction(Close)); _deathNote = deathNote; onExit = (Action)Delegate.Combine(onExit, new Action(OnExit)); foreach (PlayerControllerB player in deathNote.playerList) { if (!player.isPlayerDead) { DeathNoteName component = Object.Instantiate<GameObject>(namesPrefab, contentContainer).GetComponent<DeathNoteName>(); component.Initialize(((Component)player).gameObject, _deathNote, this); } } foreach (EnemyAI enemy in deathNote.enemyList) { if (!enemy.isEnemyDead && enemy.enemyType.canDie) { DeathNoteName component2 = Object.Instantiate<GameObject>(namesPrefab, contentContainer).GetComponent<DeathNoteName>(); component2.Initialize(((Component)enemy).gameObject, _deathNote, this); } } } private void OnExit() { Object.Destroy((Object)(object)((Component)this).gameObject); } public void Close() { onExit?.Invoke(); } } public class DeathNoteName : MonoBehaviour { [SerializeField] private TMP_Text nameText; [SerializeField] private Button killButton; private GameObject _objectToKill; private DeathNote _deathNote; private DeathNoteCanvas _deathNoteCanvas; public void Initialize(GameObject objectToKill, DeathNote deathNote, DeathNoteCanvas deathNoteCanvas) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown _deathNote = deathNote; _objectToKill = objectToKill; _deathNoteCanvas = deathNoteCanvas; if (Object.op_Implicit((Object)(object)objectToKill.GetComponent<PlayerControllerB>())) { nameText.text = objectToKill.GetComponent<PlayerControllerB>().playerUsername; } else { nameText.text = ((object)objectToKill.GetComponent<EnemyAI>().enemyType).ToString(); } ((UnityEvent)killButton.onClick).AddListener(new UnityAction(Kill)); } private void Kill() { _deathNote.ActivateDeathNote(_objectToKill); _deathNoteCanvas.Close(); } } public class Food : NoisemakerProp { [SerializeField] private int healAmount; [SerializeField] private float refuelAmount; public override void ItemActivate(bool used, bool buttonDown = true) { if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null)) { if (((GrabbableObject)this).playerHeldBy.sprintMeter + refuelAmount > 1f) { ((GrabbableObject)this).playerHeldBy.sprintMeter = 1f; } else { PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy; playerHeldBy.sprintMeter += refuelAmount; } if (((GrabbableObject)this).playerHeldBy.health + healAmount > 100) { ((GrabbableObject)this).playerHeldBy.health = 100; } else { PlayerControllerB playerHeldBy2 = ((GrabbableObject)this).playerHeldBy; playerHeldBy2.health += healAmount; } ((MonoBehaviour)this).StartCoroutine(DestroyDelay()); ChillaxModPlugin.logger.LogInfo((object)"[CHILLAX] EAT FOOD!!"); ((NoisemakerProp)this).ItemActivate(used, buttonDown); } } private IEnumerator DestroyDelay() { yield return (object)new WaitForSeconds(0.5f); ((GrabbableObject)this).DestroyObjectInHand(((GrabbableObject)this).playerHeldBy); } protected override void __initializeVariables() { ((NoisemakerProp)this).__initializeVariables(); } protected internal override string __getTypeName() { return "Food"; } } public class UnoReverse : NoisemakerProp { public AudioClip teleportClip; public List<PlayerControllerB> playerList; public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); playerList = new List<PlayerControllerB>(); } private void UpdatePlayerList() { playerList = Object.FindObjectsOfType<PlayerControllerB>().ToList(); } public override void ItemActivate(bool used, bool buttonDown = true) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) ((NoisemakerProp)this).ItemActivate(used, buttonDown); UpdatePlayerList(); foreach (PlayerControllerB player in playerList) { Debug.Log((object)("[CHILLAX] [UNO REVERSE] Players in Game: " + player.playerUsername)); } playerList.Remove(((GrabbableObject)this).playerHeldBy); int index = Random.Range(0, playerList.Count); if (playerList.Count <= 0) { Debug.LogWarning((object)"[CHILLAX] [UNO REVERSE] No players to swap with"); } foreach (PlayerControllerB player2 in playerList) { Debug.Log((object)("[CHILLAX] [UNO REVERSE] Potential Swappers: " + player2.playerUsername)); } PlayerControllerB val = playerList[index]; Vector3 serverPlayerPosition = ((GrabbableObject)this).playerHeldBy.serverPlayerPosition; Vector3 serverPlayerPosition2 = val.serverPlayerPosition; SwapServerRpc(serverPlayerPosition, serverPlayerPosition2, ((NetworkBehaviour)val).OwnerClientId); ((MonoBehaviour)this).StartCoroutine(DestroyDelay()); } [ServerRpc(RequireOwnership = false)] private void SwapServerRpc(Vector3 firstPosition, Vector3 secondPosition, ulong otherId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1423553523u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref firstPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref secondPosition); BytePacker.WriteValueBitPacked(val2, otherId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1423553523u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { Teleport(firstPosition, secondPosition, otherId); } } } private void Teleport(Vector3 firstPosition, Vector3 secondPosition, ulong otherId) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) ClientRpcParams val = default(ClientRpcParams); val.Send = new ClientRpcSendParams { TargetClientIds = new ulong[1] { ((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).OwnerClientId } }; ClientRpcParams clientRpcParams = val; val = default(ClientRpcParams); val.Send = new ClientRpcSendParams { TargetClientIds = new ulong[1] { otherId } }; ClientRpcParams clientRpcParams2 = val; TeleportOnClientRpc(secondPosition, clientRpcParams); TeleportOnClientRpc(firstPosition, clientRpcParams2); PlayExtraClipClientRpc(clientRpcParams2); } [ClientRpc] private void TeleportOnClientRpc(Vector3 position, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(40319756u, clientRpcParams, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref position); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 40319756u, clientRpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { StartOfRound.Instance.localPlayerController.TeleportPlayer(position, false, 0f, false, true); } } } [ClientRpc] private void PlayExtraClipClientRpc(ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(457107265u, clientRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 457107265u, clientRpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { AudioSource val2 = ((Component)StartOfRound.Instance.localPlayerController).gameObject.AddComponent<AudioSource>(); if (!((Object)(object)teleportClip == (Object)null)) { val2.PlayOneShot(teleportClip); Object.Destroy((Object)(object)val2, 2f); } } } private IEnumerator DestroyDelay() { yield return (object)new WaitForSeconds(1f); ((GrabbableObject)this).DestroyObjectInHand(((GrabbableObject)this).playerHeldBy); DestroyServerRpc(); } [ServerRpc(RequireOwnership = false)] private void DestroyServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3051293639u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3051293639u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((GrabbableObject)this).DestroyObjectInHand(((GrabbableObject)this).playerHeldBy); DestroyClientRpc(); } } } [ClientRpc] private void DestroyClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1058296590u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1058296590u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { ((GrabbableObject)this).DestroyObjectInHand(((GrabbableObject)this).playerHeldBy); } } } protected override void __initializeVariables() { ((NoisemakerProp)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_UnoReverse() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(1423553523u, new RpcReceiveHandler(__rpc_handler_1423553523)); NetworkManager.__rpc_func_table.Add(40319756u, new RpcReceiveHandler(__rpc_handler_40319756)); NetworkManager.__rpc_func_table.Add(457107265u, new RpcReceiveHandler(__rpc_handler_457107265)); NetworkManager.__rpc_func_table.Add(3051293639u, new RpcReceiveHandler(__rpc_handler_3051293639)); NetworkManager.__rpc_func_table.Add(1058296590u, new RpcReceiveHandler(__rpc_handler_1058296590)); } private static void __rpc_handler_1423553523(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 firstPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref firstPosition); Vector3 secondPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref secondPosition); ulong otherId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref otherId); target.__rpc_exec_stage = (__RpcExecStage)1; ((UnoReverse)(object)target).SwapServerRpc(firstPosition, secondPosition, otherId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_40319756(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)2; ((UnoReverse)(object)target).TeleportOnClientRpc(position, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_457107265(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)2; ((UnoReverse)(object)target).PlayExtraClipClientRpc(client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3051293639(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((UnoReverse)(object)target).DestroyServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1058296590(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((UnoReverse)(object)target).DestroyClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "UnoReverse"; } } }
plugins/CustomSounds.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using LCSoundTool; 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("CustomSounds")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CustomSounds")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9e086160-a7fd-4721-ba09-3e8534cb7011")] [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 CustomSounds; [BepInPlugin("CustomSounds", "Custom Sounds", "1.2.0")] public class Plugin : BaseUnityPlugin { private const string PLUGIN_GUID = "CustomSounds"; private const string PLUGIN_NAME = "Custom Sounds"; private const string PLUGIN_VERSION = "1.2.0"; public static Plugin Instance; internal ManualLogSource logger; private Harmony harmony; public HashSet<string> currentSounds = new HashSet<string>(); public HashSet<string> oldSounds = new HashSet<string>(); public HashSet<string> modifiedSounds = new HashSet<string>(); public Dictionary<string, string> soundHashes = new Dictionary<string, string>(); public Dictionary<string, string> soundPacks = new Dictionary<string, string>(); private void Awake() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown if (!((Object)(object)Instance == (Object)null)) { return; } Instance = this; logger = Logger.CreateLogSource("CustomSounds"); logger.LogInfo((object)"Plugin CustomSounds is loaded!"); harmony = new Harmony("CustomSounds"); harmony.PatchAll(); modifiedSounds = new HashSet<string>(); string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "CustomSounds"); if (!Directory.Exists(path)) { logger.LogInfo((object)"\"CustomSounds\" folder not found. Creating it now."); Directory.CreateDirectory(path); } string path2 = Path.Combine(Paths.BepInExConfigPath); try { List<string> list = File.ReadAllLines(path2).ToList(); int num = list.FindIndex((string line) => line.StartsWith("HideManagerGameObject")); if (num != -1) { logger.LogInfo((object)"\"hideManagerGameObject\" value not correctly set. Fixing it now."); list[num] = "HideManagerGameObject = true"; } File.WriteAllLines(path2, list); } catch (Exception ex) { logger.LogError((object)("Erreur lors de la modification du fichier de configuration: " + ex.Message)); } } public void RevertSounds() { foreach (string currentSound in currentSounds) { logger.LogInfo((object)(currentSound + " restored.")); SoundTool.RestoreAudioClip(currentSound); } logger.LogInfo((object)"Original game sounds restored."); } public static string CalculateMD5(string filename) { using MD5 mD = MD5.Create(); using FileStream inputStream = File.OpenRead(filename); byte[] array = mD.ComputeHash(inputStream); return BitConverter.ToString(array).Replace("-", "").ToLowerInvariant(); } public void ReloadSounds() { foreach (string currentSound in currentSounds) { SoundTool.RestoreAudioClip(currentSound); } oldSounds = new HashSet<string>(currentSounds); modifiedSounds.Clear(); string directoryName = Path.GetDirectoryName(Paths.PluginPath); currentSounds.Clear(); ProcessDirectory(directoryName); } private void ProcessDirectory(string directoryPath) { string[] directories = Directory.GetDirectories(directoryPath, "CustomSounds", SearchOption.AllDirectories); foreach (string text in directories) { string fileName = Path.GetFileName(Path.GetDirectoryName(text)); ProcessSoundFiles(text, fileName); string[] directories2 = Directory.GetDirectories(text); foreach (string text2 in directories2) { string fileName2 = Path.GetFileName(text2); ProcessSoundFiles(text2, fileName2); } } } private void ProcessSoundFiles(string directoryPath, string packName) { string[] files = Directory.GetFiles(directoryPath, "*.wav"); foreach (string text in files) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); string text2 = CalculateMD5(text); if (soundHashes.TryGetValue(fileNameWithoutExtension, out var value) && value != text2) { modifiedSounds.Add(fileNameWithoutExtension); } AudioClip audioClip = SoundTool.GetAudioClip(directoryPath, "", text); SoundTool.ReplaceAudioClip(fileNameWithoutExtension, audioClip); soundHashes[fileNameWithoutExtension] = text2; currentSounds.Add(fileNameWithoutExtension); soundPacks[fileNameWithoutExtension] = packName; logger.LogInfo((object)("[" + packName + "] " + fileNameWithoutExtension + " sound replaced!")); } } public string GetSoundChanges() { StringBuilder stringBuilder = new StringBuilder("Customsounds reloaded.\n\n"); HashSet<string> arg = new HashSet<string>(currentSounds.Except(oldSounds)); HashSet<string> arg2 = new HashSet<string>(oldSounds.Except(currentSounds)); HashSet<string> arg3 = new HashSet<string>(oldSounds.Intersect(currentSounds).Except(modifiedSounds)); HashSet<string> arg4 = new HashSet<string>(modifiedSounds); Dictionary<string, List<string>> soundsByPack = new Dictionary<string, List<string>>(); Action<HashSet<string>, string> action = delegate(HashSet<string> soundsSet, string status) { foreach (string item in soundsSet) { string key = soundPacks[item]; if (!soundsByPack.ContainsKey(key)) { soundsByPack[key] = new List<string>(); } soundsByPack[key].Add(item + " (" + status + ")"); } }; action(arg, "New"); action(arg2, "Deleted"); action(arg4, "Modified"); action(arg3, "Already Existed"); foreach (string key2 in soundsByPack.Keys) { stringBuilder.AppendLine(key2 + " :"); foreach (string item2 in soundsByPack[key2]) { stringBuilder.AppendLine("- " + item2); } stringBuilder.AppendLine(); } return stringBuilder.ToString(); } public string ListAllSounds() { StringBuilder stringBuilder = new StringBuilder("Listing all currently loaded custom sounds:\n\n"); Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>(); foreach (string currentSound in currentSounds) { string key = soundPacks[currentSound]; if (!dictionary.ContainsKey(key)) { dictionary[key] = new List<string>(); } dictionary[key].Add(currentSound); } foreach (string key2 in dictionary.Keys) { stringBuilder.AppendLine(key2 + " :"); foreach (string item in dictionary[key2]) { stringBuilder.AppendLine("- " + item); } stringBuilder.AppendLine(); } return stringBuilder.ToString(); } private void Start() { ReloadSounds(); } } [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] public static class TerminalParsePlayerSentencePatch { public static bool Prefix(Terminal __instance, ref TerminalNode __result) { string[] array = __instance.screenText.text.Split(new char[1] { '\n' }); if (array.Length == 0) { return true; } string[] array2 = array.Last().Trim().ToLower() .Split(new char[1] { ' ' }); if (array2.Length == 0 || array2[0] != "customsounds") { return true; } Plugin.Instance.logger.LogInfo((object)("Received terminal command: " + string.Join(" ", array2))); if (array2.Length > 1 && array2[0] == "customsounds") { switch (array2[1]) { case "reload": Plugin.Instance.ReloadSounds(); __result = CreateTerminalNode(Plugin.Instance.GetSoundChanges()); return false; case "revert": Plugin.Instance.RevertSounds(); __result = CreateTerminalNode("Game sounds reverted to original."); return false; case "list": __result = CreateTerminalNode(Plugin.Instance.ListAllSounds()); return false; case "help": __result = CreateTerminalNode("CustomSounds commands.\n\n>CUSTOMSOUNDS LIST\nTo displays all currently loaded sounds\n\n>CUSTOMSOUNDS RELOAD\nTo reloads and applies sounds from the 'CustomSounds' folder and its subfolders.\n\n>CUSTOMSOUNDS REVERT\nTo unloads all custom sounds and restores original game sounds"); return false; default: __result = CreateTerminalNode("Unknown customsounds command."); return false; } } return true; } private static TerminalNode CreateTerminalNode(string message) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown return new TerminalNode { displayText = message, clearPreviousText = true }; } }
plugins/HelmetCamera.dll
Decompiled 2 years agousing System; using 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 HarmonyLib; 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("HelmetCamera")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HelmetCamera")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b99c4d46-5f13-47b3-a5af-5e3f37772e77")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace HelmetCamera { [BepInPlugin("RickArg.lethalcompany.helmetcameras", "Helmet_Cameras", "2.1.5")] public class PluginInit : BaseUnityPlugin { public static Harmony _harmony; public static ConfigEntry<int> config_isHighQuality; public static ConfigEntry<int> config_renderDistance; public static ConfigEntry<int> config_cameraFps; private void Awake() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown config_isHighQuality = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "monitorResolution", 0, "Low FPS affection. High Quality mode. 0 - vanilla (48x48), 1 - vanilla+ (128x128), 2 - mid quality (256x256), 3 - high quality (512x512), 4 - Very High Quality (1024x1024)"); config_renderDistance = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "renderDistance", 20, "Low FPS affection. Render distance for helmet camera."); config_cameraFps = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "cameraFps", 30, "Very high FPS affection. FPS for helmet camera. To increase YOUR fps, you should low cameraFps value."); _harmony = new Harmony("HelmetCamera"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Helmet_Cameras is loaded with version 2.1.5!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"--------Helmet camera patch done.---------"); } } public static class PluginInfo { public const string PLUGIN_GUID = "RickArg.lethalcompany.helmetcameras"; public const string PLUGIN_NAME = "Helmet_Cameras"; public const string PLUGIN_VERSION = "2.1.5"; } public class Plugin : MonoBehaviour { private RenderTexture renderTexture; private bool isMonitorChanged = false; private GameObject helmetCameraNew; private bool isSceneLoaded = false; private bool isCoroutineStarted = false; private int currentTransformIndex; private int resolution = 0; private int renderDistance = 50; private float cameraFps = 30f; private float elapsed; private void Awake() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown resolution = PluginInit.config_isHighQuality.Value; renderDistance = PluginInit.config_renderDistance.Value; cameraFps = PluginInit.config_cameraFps.Value; switch (resolution) { case 0: renderTexture = new RenderTexture(48, 48, 24); break; case 1: renderTexture = new RenderTexture(128, 128, 24); break; case 2: renderTexture = new RenderTexture(256, 256, 24); break; case 3: renderTexture = new RenderTexture(512, 512, 24); break; case 4: renderTexture = new RenderTexture(1024, 1024, 24); break; } } public void Start() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) isCoroutineStarted = false; while ((Object)(object)helmetCameraNew == (Object)null) { helmetCameraNew = new GameObject("HelmetCamera"); } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "MainMenu") { activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "InitScene") { activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "InitSceneLaunchOptions") { isSceneLoaded = true; Debug.Log((object)"[HELMET_CAMERAS] Starting coroutine..."); ((MonoBehaviour)this).StartCoroutine(LoadSceneEnter()); return; } } } isSceneLoaded = false; isMonitorChanged = false; } private IEnumerator LoadSceneEnter() { Debug.Log((object)"[HELMET_CAMERAS] 5 seconds for init mode... Please wait..."); yield return (object)new WaitForSeconds(5f); isCoroutineStarted = true; if ((Object)(object)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera") != (Object)null) { Debug.Log((object)"[HELMET_CAMERAS] Ship camera founded..."); if (!isMonitorChanged) { ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube").GetComponent<MeshRenderer>()).materials[2].mainTexture = ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture; ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture = (Texture)(object)renderTexture; helmetCameraNew.AddComponent<Camera>(); ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false; helmetCameraNew.GetComponent<Camera>().targetTexture = renderTexture; helmetCameraNew.GetComponent<Camera>().cullingMask = 20649983; helmetCameraNew.GetComponent<Camera>().farClipPlane = renderDistance; helmetCameraNew.GetComponent<Camera>().nearClipPlane = 0.55f; isMonitorChanged = true; Debug.Log((object)"[HELMET_CAMERAS] Monitors were changed..."); Debug.Log((object)"[HELMET_CAMERAS] Turning off vanilla internal ship camera"); ((Behaviour)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera").GetComponent<Camera>()).enabled = false; } } } public void Update() { //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) bool flag = isSceneLoaded && isCoroutineStarted; if (flag && StartOfRound.Instance.localPlayerController.isInHangarShipRoom) { helmetCameraNew.SetActive(true); elapsed += Time.deltaTime; if (elapsed > 1f / cameraFps) { elapsed = 0f; ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = true; } else { ((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false; } GameObject val = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001/CameraMonitorScript"); currentTransformIndex = val.GetComponent<ManualCameraRenderer>().targetTransformIndex; TransformAndName val2 = val.GetComponent<ManualCameraRenderer>().radarTargets[currentTransformIndex]; if (!val2.isNonPlayer) { try { helmetCameraNew.transform.SetPositionAndRotation(val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").position + new Vector3(0f, 0f, 0f), val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").rotation * Quaternion.Euler(0f, 0f, 0f)); DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>(); for (int i = 0; i < array.Length; i++) { if (array[i].playerScript.playerUsername == val2.name) { helmetCameraNew.transform.SetPositionAndRotation(((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").position, ((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").rotation * Quaternion.Euler(0f, 0f, 0f)); } } return; } catch (NullReferenceException) { Debug.Log((object)"[HELMET_CAMERAS] ERROR NULL REFERENCE"); return; } } helmetCameraNew.transform.SetPositionAndRotation(val2.transform.position + new Vector3(0f, 1.6f, 0f), val2.transform.rotation * Quaternion.Euler(0f, -90f, 0f)); } else if (flag && !StartOfRound.Instance.localPlayerController.isInHangarShipRoom) { helmetCameraNew.SetActive(false); } } } } namespace HelmetCamera.Patches { [HarmonyPatch] internal class HelmetCamera { public static void InitCameras() { GameObject val = GameObject.Find("Environment/HangarShip/Cameras/ShipCamera"); val.AddComponent<Plugin>(); } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] public static void InitCamera(ref ManualCameraRenderer __instance) { InitCameras(); } } }
plugins/HoldScanButton.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using HoldScanButton.Patches; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HoldScanButton")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A mod which allows you to hold the scan button instead of needing to spam it.")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+92607af20e0f471d869a59ef64bf096440b07cf2")] [assembly: AssemblyProduct("HoldScanButton")] [assembly: AssemblyTitle("HoldScanButton")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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 HoldScanButton { [BepInPlugin("HoldScanButton", "HoldScanButton", "1.1.1")] public class HoldScanButtonPlugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("HoldScanButton"); public static HoldScanButtonPlugin Instance; internal ManualLogSource logger; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } logger = Logger.CreateLogSource("HoldScanButton"); logger.LogInfo((object)"Plugin HoldScanButton has loaded!"); harmony.PatchAll(typeof(HoldScanButtonPatch)); } } public static class PluginInfo { public const string PLUGIN_GUID = "HoldScanButton"; public const string PLUGIN_NAME = "HoldScanButton"; public const string PLUGIN_VERSION = "1.1.1"; } } namespace HoldScanButton.Patches { internal class HoldScanButtonPatch { private static CallbackContext pingContext; [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPostfix] private static void UpdatePatch(HUDManager __instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (IngamePlayerSettings.Instance.playerInput.actions.FindAction("PingScan", false).IsPressed()) { __instance.PingScan_performed(pingContext); } } [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] [HarmonyPrefix] private static void OnScan(HUDManager __instance, CallbackContext context) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) pingContext = context; } } }
plugins/LateCompanyV1.0.6.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; 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.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("LateCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+31dbb98cfa5670c23f3ffb21c05582c54159b82d")] [assembly: AssemblyProduct("LateCompany")] [assembly: AssemblyTitle("LateCompany")] [assembly: AssemblyVersion("1.0.0.0")] [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 LateCompany { public static class PluginInfo { public const string GUID = "twig.latecompany"; public const string PrintName = "Late Company"; public const string Version = "1.0.6"; } [BepInPlugin("twig.latecompany", "Late Company", "1.0.6")] internal class Plugin : BaseUnityPlugin { private ConfigEntry<bool> configLateJoinOrbitOnly; public static bool OnlyLateJoinInOrbit = false; public static bool LobbyJoinable = true; public void Awake() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown configLateJoinOrbitOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Late join orbit only", true, "Don't allow joining while the ship is not in orbit."); OnlyLateJoinInOrbit = configLateJoinOrbitOnly.Value; Harmony val = new Harmony("twig.latecompany"); val.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Late Company loaded!"); } public static void SetLobbyJoinable(bool joinable) { LobbyJoinable = joinable; GameNetworkManager.Instance.SetLobbyJoinable(joinable); QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>(); if (Object.op_Implicit((Object)(object)val)) { val.inviteFriendsTextAlpha.alpha = (joinable ? 1f : 0.2f); } } } } namespace LateCompany.Patches { [HarmonyPatch(typeof(GameNetworkManager), "LeaveLobbyAtGameStart")] [HarmonyWrapSafe] internal static class LeaveLobbyAtGameStart_Patch { [HarmonyPrefix] private static bool Prefix() { return false; } } [HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")] [HarmonyWrapSafe] internal static class ConnectionApproval_Patch { [HarmonyPostfix] private static void Postfix(ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (request.ClientNetworkId != NetworkManager.Singleton.LocalClientId && response.Reason.Contains("Game has already started") && Plugin.LobbyJoinable) { response.Reason = ""; response.CreatePlayerObject = false; response.Approved = true; response.Pending = false; } } } [HarmonyPatch(typeof(QuickMenuManager), "DisableInviteFriendsButton")] [HarmonyWrapSafe] internal static class DisableInviteFriendsButton_Patch { [HarmonyPrefix] private static bool Prefix() { return false; } } [HarmonyPatch(typeof(QuickMenuManager), "InviteFriendsButton")] [HarmonyWrapSafe] internal static class InviteFriendsButton_Patch { [HarmonyPrefix] private static bool Prefix() { if (Plugin.LobbyJoinable) { GameNetworkManager.Instance.InviteFriendsUI(); } return false; } } internal class RpcEnum : NetworkBehaviour { public static int None => 0; public static int Client => 2; public static int Server => 1; } internal static class WeatherSync { public static bool DoOverride = false; public static LevelWeatherType CurrentWeather = (LevelWeatherType)(-1); } [HarmonyPatch(typeof(RoundManager), "__rpc_handler_1193916134")] [HarmonyWrapSafe] internal static class __rpc_handler_1193916134_Patch { public static FieldInfo RPCExecStage = typeof(NetworkBehaviour).GetField("__rpc_exec_stage", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPrefix] private static bool Prefix(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; try { int num = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num); int num2 = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num2); int num3 = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref num3); WeatherSync.DoOverride = true; WeatherSync.CurrentWeather = (LevelWeatherType)num3; RPCExecStage.SetValue(target, RpcEnum.Client); ((RoundManager)((target is RoundManager) ? target : null)).GenerateNewLevelClientRpc(num, num2); RPCExecStage.SetValue(target, RpcEnum.None); } catch { ((FastBufferReader)(ref reader)).Seek(0); return true; } return false; } } [HarmonyPatch(typeof(RoundManager), "SetToCurrentLevelWeather")] [HarmonyWrapSafe] internal static class SetToCurrentLevelWeather_Patch { [HarmonyPrefix] private static bool Prefix() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!WeatherSync.DoOverride) { return true; } WeatherSync.DoOverride = false; TimeOfDay.Instance.currentLevelWeather = WeatherSync.CurrentWeather; return false; } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")] [HarmonyWrapSafe] internal class OnPlayerConnectedClientRpc_Patch { public static MethodInfo BeginSendClientRpc = typeof(RoundManager).GetMethod("__beginSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic); public static MethodInfo EndSendClientRpc = typeof(RoundManager).GetMethod("__endSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPostfix] private static void Postfix(ulong clientId, int connectedPlayers, ulong[] connectedPlayerIdsOrdered, int assignedPlayerObjectId, int serverMoneyAmount, int levelID, int profitQuota, int timeUntilDeadline, int quotaFulfilled, int randomSeed) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; PlayerControllerB val = instance.allPlayerScripts[assignedPlayerObjectId]; if (instance.connectedPlayersAmount + 1 >= instance.allPlayerScripts.Length) { Plugin.SetLobbyJoinable(joinable: false); } val.DisablePlayerModel(instance.allPlayerObjects[assignedPlayerObjectId], true, true); if (((NetworkBehaviour)instance).IsServer && !instance.inShipPhase) { RoundManager instance2 = RoundManager.Instance; ClientRpcParams val2 = default(ClientRpcParams); val2.Send = new ClientRpcSendParams { TargetClientIds = new List<ulong> { clientId } }; ClientRpcParams val3 = val2; FastBufferWriter val4 = (FastBufferWriter)BeginSendClientRpc.Invoke(instance2, new object[3] { 1193916134u, val3, 0 }); BytePacker.WriteValueBitPacked(val4, StartOfRound.Instance.randomMapSeed); BytePacker.WriteValueBitPacked(val4, StartOfRound.Instance.currentLevelID); BytePacker.WriteValueBitPacked(val4, (short)instance2.currentLevel.currentWeather); EndSendClientRpc.Invoke(instance2, new object[4] { val4, 1193916134u, val3, 0 }); FastBufferWriter val5 = (FastBufferWriter)BeginSendClientRpc.Invoke(instance2, new object[3] { 2729232387u, val3, 0 }); EndSendClientRpc.Invoke(instance2, new object[4] { val5, 2729232387u, val3, 0 }); } instance.livingPlayers = instance.connectedPlayersAmount + 1; for (int i = 0; i < instance.allPlayerScripts.Length; i++) { PlayerControllerB val6 = instance.allPlayerScripts[i]; if (val6.isPlayerControlled && val6.isPlayerDead) { instance.livingPlayers--; } } } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] [HarmonyWrapSafe] internal class OnPlayerDC_Patch { [HarmonyPostfix] public static void Postfix() { if (StartOfRound.Instance.inShipPhase || !Plugin.OnlyLateJoinInOrbit) { Plugin.SetLobbyJoinable(joinable: true); } } } [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyWrapSafe] internal class StartGame_Patch { [HarmonyPrefix] public static void Prefix() { if (Plugin.OnlyLateJoinInOrbit) { Plugin.SetLobbyJoinable(joinable: false); } } } [HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")] [HarmonyWrapSafe] internal class SetShipReadyToLand_Patch { [HarmonyPrefix] public static void Postfix() { if (Plugin.OnlyLateJoinInOrbit && StartOfRound.Instance.connectedPlayersAmount + 1 < StartOfRound.Instance.allPlayerScripts.Length) { Plugin.SetLobbyJoinable(joinable: true); } } } }
plugins/LCOuijaBoard.dll
Decompiled 2 years agousing System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using LCOuijaBoard.Properties; using LethalLib.Modules; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LCOuijaBoard")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LCOuijaBoard")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1c1acc88-8f86-45d6-beb9-9b98f2302980")] [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")] internal class <Module> { static <Module>() { } } namespace LCOuijaBoard { [BepInPlugin("Electric.OuijaBoard", "OuijaBoard", "1.4.0")] public class Plugin : BaseUnityPlugin { private class UIHandler { public static GameObject inputObject; public static TMP_InputField input; public static bool registered; public static float lastError; public static TMP_InputField GetInput() { if (registered && (Object)(object)input != (Object)null) { return input; } inputObject = ((Component)OuijaTextUI.transform.GetChild(2)).gameObject; input = inputObject.GetComponent<TMP_InputField>(); ((UnityEvent<string>)(object)input.onSubmit).AddListener((UnityAction<string>)SubmitUI); ((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)EndEditUI); registered = true; return input; } public static void hide() { OuijaTextUI.SetActive(false); input.text = ""; } public static void ToggleUI(CallbackContext context) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; Debug.Log((object)"Ouija Text UI Toggle Requested"); if (!DEVDEBUG && ((Object)(object)localPlayerController == (Object)null || !localPlayerController.isPlayerDead)) { Debug.Log((object)"Ouija Text UI Toggle Denied: Not Dead"); return; } if ((Object)(object)OuijaTextUI == (Object)null) { Debug.LogError((object)"Ouija Text UI Toggle Denied: No UI"); return; } bool flag = !OuijaTextUI.active; GetInput(); Debug.Log((object)$"Ouija Text UI Toggle Accepted: New State is {flag}"); if (!flag) { if (!input.isFocused || !OuijaTextUI.active) { OuijaTextUI.SetActive(false); } } else { OuijaTextUI.SetActive(true); input.ActivateInputField(); ((Selectable)input).Select(); } } public static void SubmitUI(string msg) { AttemptSend(msg); } public static void EndEditUI(string msg) { hide(); } public static bool AttemptSend(string msg) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) string[] value = msg.Split(new char[1] { ' ' }).ToArray(); Object[] array = Object.FindObjectsOfType(typeof(GameObject)); List<GameObject> list = new List<GameObject>(); Object[] array2 = array; for (int i = 0; i < array2.Length; i++) { GameObject val = (GameObject)array2[i]; if ((((Object)val).name == "OuijaBoardScrap(Clone)" || ((Object)val).name == "OuijaBoardStore(Clone)") && !((GrabbableObject)(PhysicsProp)val.GetComponent(typeof(PhysicsProp))).isHeld) { list.Add(val); } } if (list.Count > 0) { if (!StartOfRoundPatch.complete) { ShowError("Boards on cooldown"); return false; } string text = string.Join("", value); if (Regex.Match(text, "([A-Za-z\\d ])+").Value.Length != text.Length) { ShowError("Invalid character(s)"); return false; } text = text.Replace(" ", ""); if (text.Length > 10) { ShowError("Too many characters"); return false; } OuijaNetworker.Instance.WriteOut(text); return true; } ShowError("No valid boards"); return false; } public static void ShowError(string msg) { if ((Object)(object)OuijaErrorUI != (Object)null) { Debug.Log((object)("Ouija Board showing erorr: " + msg)); ((Component)OuijaErrorUI.transform.GetChild(0)).GetComponent<TMP_Text>().text = msg; OuijaErrorUI.SetActive(true); lastError = Time.time; } } } [HarmonyPatch(typeof(StartOfRound))] public class StartOfRoundPatch { public static int writeIndex = 0; public static List<string> names = new List<string>(); public static List<GameObject> boards = new List<GameObject>(); public static float timer = 0f; public static double amount = 0.0; public static bool complete = true; [HarmonyPatch("Update")] [HarmonyPostfix] private static void Update(ref StartOfRound __instance) { PlayerControllerB localPlayerController = __instance.localPlayerController; if (!DEVDEBUG && !localPlayerController.isPlayerDead && Object.op_Implicit((Object)(object)OuijaTextUI) && OuijaTextUI.active) { Debug.Log((object)"Ouija Text UI closed since player is not dead"); OuijaTextUI.SetActive(false); } if (Object.op_Implicit((Object)(object)OuijaErrorUI) && OuijaErrorUI.active && Time.time - UIHandler.lastError > 2f) { Debug.Log((object)"Ouija Error UI closed"); OuijaErrorUI.SetActive(false); } if (writeIndex < names.Count) { amount = Mathf.Clamp(timer / 1.2f, 0f, 1f); MoveUpdate(names[writeIndex]); timer += Time.deltaTime; if (timer >= 3f) { amount = 1.0; MoveUpdate(names[writeIndex]); timer = 0f; writeIndex++; } } else if (!complete) { if (timer < 5f) { timer += Time.deltaTime; } else { complete = true; timer = 0f; amount = 0.0; } } if ((Object)(object)OuijaTextUI != (Object)null) { ((Component)OuijaTextUI.transform.GetChild(3)).gameObject.SetActive(!complete); } } public static void MoveUpdate(string name) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown int num = -1; bool flag = false; PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; foreach (GameObject board in boards) { if (!Object.op_Implicit((Object)(object)board) || ((GrabbableObject)(PhysicsProp)board.GetComponent(typeof(PhysicsProp))).isHeld) { continue; } flag = true; if (num == -1) { num = 0; foreach (Transform item in board.transform.GetChild(0).GetChild(3)) { Transform val = item; GameObject gameObject = ((Component)val).gameObject; if (((Object)gameObject).name == name) { break; } num++; } if (num == -1) { amount = 0.0; writeIndex++; break; } } Vector3 localPosition = board.transform.GetChild(0).GetChild(3).GetChild(num) .localPosition; Vector3 localPosition2 = board.transform.GetChild(0).GetChild(4).localPosition; GameObject gameObject2 = ((Component)board.transform.GetChild(0).GetChild(2)).gameObject; if (amount == 0.0) { gameObject2.GetComponent<AudioSource>().Play(); if (makesSound) { RoundManager.Instance.PlayAudibleNoise(board.transform.position, 8f, 0.3f, 0, false, 8925); } } Vector3 val2 = localPosition + new Vector3(0f, 0.166f, 0f); gameObject2.transform.localPosition = Vector3.Lerp(localPosition2, val2, (float)amount); if (amount == 1.0) { board.transform.GetChild(0).GetChild(4).localPosition = val2; } if (Vector3.Distance(((Component)localPlayerController).transform.position, board.transform.position) < 5f) { localPlayerController.insanityLevel += Time.deltaTime * 0.5f; } } if (!flag) { writeIndex = names.Count; } } } [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyPriority(500)] public class PlayerPatch { [HarmonyPatch("Interact_performed")] [HarmonyPrefix] private static void InteractPrefixPatch(ref PlayerControllerB __instance, out bool __state) { __state = __instance.isPlayerDead; if (Object.op_Implicit((Object)(object)OuijaTextUI) && OuijaTextUI.active) { __instance.isPlayerDead = false; } } [HarmonyPatch("Interact_performed")] [HarmonyPostfix] private static void InteractPostfixPatch(ref PlayerControllerB __instance, bool __state) { __instance.isPlayerDead = __state; } } public class OuijaNetworker : NetworkBehaviour { public static OuijaNetworker Instance; private void Awake() { Instance = this; } public void WriteOut(string message) { if (((NetworkBehaviour)this).IsOwner) { WriteOutClientRpc(message); } else { WriteOutServerRpc(message); } } [ClientRpc] public void WriteOutClientRpc(string message) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3508306228u, val, (RpcDelivery)0); bool flag = message != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(message, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3508306228u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } Object[] array = Object.FindObjectsOfType(typeof(GameObject)); List<GameObject> list = new List<GameObject>(); Object[] array2 = array; for (int i = 0; i < array2.Length; i++) { GameObject val3 = (GameObject)array2[i]; if ((((Object)val3).name == "OuijaBoardScrap(Clone)" || ((Object)val3).name == "OuijaBoardStore(Clone)") && !((GrabbableObject)(PhysicsProp)val3.GetComponent(typeof(PhysicsProp))).isHeld) { list.Add(val3); } } List<string> list2 = new List<string>(); switch (message) { case "yes": case "y": list2.Add("Yes"); break; case "no": case "n": list2.Add("No"); break; case "goodbye": case "bye": list2.Add("Goodbye"); break; default: list2 = (from c in message.ToUpper().ToCharArray() select c.ToString()).ToList(); break; } StartOfRoundPatch.amount = 0.0; StartOfRoundPatch.complete = false; StartOfRoundPatch.writeIndex = 0; StartOfRoundPatch.names = list2; StartOfRoundPatch.boards = list; } [ServerRpc(RequireOwnership = false)] public void WriteOutServerRpc(string message) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3320529116u, val, (RpcDelivery)0); bool flag = message != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(message, false); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3320529116u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { WriteOutClientRpc(message); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_OuijaNetworker() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(3508306228u, new RpcReceiveHandler(__rpc_handler_3508306228)); NetworkManager.__rpc_func_table.Add(3320529116u, new RpcReceiveHandler(__rpc_handler_3320529116)); } private static void __rpc_handler_3508306228(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string message = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref message, false); } target.__rpc_exec_stage = (__RpcExecStage)2; ((OuijaNetworker)(object)target).WriteOutClientRpc(message); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3320529116(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string message = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref message, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((OuijaNetworker)(object)target).WriteOutServerRpc(message); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "OuijaNetworker"; } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(ref RoundManager __instance) { if (((NetworkBehaviour)__instance).IsServer && (Object)(object)OuijaNetworker.Instance == (Object)null) { GameObject val = Object.Instantiate<GameObject>(OuijaNetworkerPrefab); val.GetComponent<NetworkObject>().Spawn(true); } OuijaTextUI = Object.Instantiate<GameObject>(OuijaTextUIPrefab); OuijaTextUI.SetActive(false); OuijaErrorUI = Object.Instantiate<GameObject>(OuijaErrorUIPrefab); OuijaErrorUI.SetActive(false); } } private const string modGUID = "Electric.OuijaBoard"; private const string modName = "OuijaBoard"; private const string modVersion = "1.4.0"; private readonly Harmony harmony = new Harmony("Electric.OuijaBoard"); private static MethodInfo chat; public static bool storeEnabled; public static int storeCost; public static bool scrapEnabled; public static int scrapRarity; public static bool makesSound; private static bool DEVDEBUG; public static GameObject OuijaNetworkerPrefab; public static GameObject OuijaTextUIPrefab; public static GameObject OuijaTextUI; public static GameObject OuijaErrorUIPrefab; public static GameObject OuijaErrorUI; private void Awake() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown AssetBundle val = AssetBundle.LoadFromMemory(Resources.fullboard); OuijaNetworkerPrefab = val.LoadAsset<GameObject>("Assets/OuijaNetworker.prefab"); OuijaNetworkerPrefab.AddComponent<OuijaNetworker>(); OuijaTextUIPrefab = val.LoadAsset<GameObject>("Assets/OuijaTextUI.prefab"); OuijaErrorUIPrefab = val.LoadAsset<GameObject>("Assets/OuijaErrorUI.prefab"); GameObject val2 = val.LoadAsset<GameObject>("Assets/OuijaBoardStore.prefab"); GameObject val3 = val.LoadAsset<GameObject>("Assets/OuijaBoardScrap.prefab"); NetworkPrefabs.RegisterNetworkPrefab(OuijaNetworkerPrefab); NetworkPrefabs.RegisterNetworkPrefab(val2); NetworkPrefabs.RegisterNetworkPrefab(val3); InputAction val4 = new InputAction((string)null, (InputActionType)0, "<Keyboard>/#(o)", (string)null, (string)null, (string)null); val4.performed += UIHandler.ToggleUI; val4.Enable(); chat = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); storeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Store", "Enabled", true, "Allow Ouija Board to be bought in the store").Value; storeCost = ((BaseUnityPlugin)this).Config.Bind<int>("Store", "Cost", 100, "Cost of a Ouija Board in the store (Store must be enabled)").Value; scrapEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Scrap", "Enabled", false, "Allow the Ouija Board to spawn in the facility").Value; scrapRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "Rarity Weight", 20, "Chance for a Ouija Board to spawn as scrap").Value; if (storeCost < 0) { storeCost = 0; } if (scrapRarity < 0) { scrapRarity = 0; } makesSound = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Makes Sound", true, "Enables the Ouija Board's sliding to be heard by enemies").Value; Item val5 = val.LoadAsset<Item>("Assets/OuijaBoardStoreItem.asset"); Item val6 = val.LoadAsset<Item>("Assets/OuijaBoardScrapItem.asset"); if (storeEnabled) { Debug.Log((object)$"Ouija Board store enabled at {storeCost} credits"); Items.RegisterShopItem(val5, storeCost); } if (scrapEnabled) { Debug.Log((object)$"Ouija Board scrap spawn enabled at {scrapRarity} rarity weight"); Items.RegisterScrap(val6, scrapRarity, (LevelTypes)510); } NetcodeWeaver(); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"OuijaBoard loaded!"); } private static void NetcodeWeaver() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } } } namespace LCOuijaBoard.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { ResourceManager resourceManager = new ResourceManager("LCOuijaBoard.Properties.Resources", typeof(Resources).Assembly); resourceMan = resourceManager; } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] fullboard { get { object @object = ResourceManager.GetObject("fullboard", resourceCulture); return (byte[])@object; } } internal Resources() { } } }
plugins/LC_API.dll
Decompiled 2 years agousing System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LC_API.BundleAPI; using LC_API.Comp; using LC_API.Data; using LC_API.Extensions; using LC_API.GameInterfaceAPI; using LC_API.ManualPatches; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("LC_API")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Utilities for plugin devs")] [assembly: AssemblyFileVersion("2.1.1.0")] [assembly: AssemblyInformationalVersion("2.1.1")] [assembly: AssemblyProduct("LC_API")] [assembly: AssemblyTitle("LC_API")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.1.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 LC_API { internal static class CheatDatabase { private const string DAT_CD_BROADCAST = "LC_API_CD_Broadcast"; private const string SIG_REQ_GUID = "LC_API_ReqGUID"; private const string SIG_SEND_MODS = "LC_APISendMods"; private static Dictionary<string, PluginInfo> PluginsLoaded = new Dictionary<string, PluginInfo>(); public static void RunLocalCheatDetector() { PluginsLoaded = Chainloader.PluginInfos; using Dictionary<string, PluginInfo>.ValueCollection.Enumerator enumerator = PluginsLoaded.Values.GetEnumerator(); while (enumerator.MoveNext()) { switch (enumerator.Current.Metadata.GUID) { case "mikes.lethalcompany.mikestweaks": case "mom.llama.enhancer": case "Posiedon.GameMaster": case "LethalCompanyScalingMaster": case "verity.amberalert": ModdedServer.SetServerModdedOnly(); break; } } } public static void OtherPlayerCheatDetector() { Plugin.Log.LogWarning((object)"Asking all other players for their mod list.."); GameTips.ShowTip("Mod List:", "Asking all other players for installed mods.."); GameTips.ShowTip("Mod List:", "Check the logs for more detailed results.\n<size=13>(Note that if someone doesnt show up on the list, they may not have LC_API installed)</size>"); Networking.Broadcast("LC_API_CD_Broadcast", "LC_API_ReqGUID"); } internal static void CDNetGetString(string data, string signature) { if (data == "LC_API_CD_Broadcast" && signature == "LC_API_ReqGUID") { string text = ""; foreach (PluginInfo value in PluginsLoaded.Values) { text = text + "\n" + value.Metadata.GUID; } Networking.Broadcast(GameNetworkManager.Instance.localPlayerController.playerUsername + " responded with these mods:" + text, "LC_APISendMods"); } if (signature == "LC_APISendMods") { GameTips.ShowTip("Mod List:", data); Plugin.Log.LogWarning((object)data); } } } [BepInPlugin("LC_API", "LC_API", "2.1.1")] public sealed class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private ConfigEntry<bool> configOverrideModServer; private ConfigEntry<bool> configLegacyAssetLoading; private ConfigEntry<bool> configDisableBundleLoader; public static bool Initialized { get; private set; } private void Awake() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown configOverrideModServer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Force modded server browser", false, "Should the API force you into the modded server browser?"); configLegacyAssetLoading = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Legacy asset bundle loading", false, "Should the BundleLoader use legacy asset loading? Turning this on may help with loading assets from older plugins."); configDisableBundleLoader = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable BundleLoader", false, "Should the BundleLoader be turned off? Enable this if you are having problems with mods that load assets using a different method from LC_API's BundleLoader."); Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogWarning((object)"\n.____ _________ _____ __________ .___ \r\n| | \\_ ___ \\ / _ \\ \\______ \\| | \r\n| | / \\ \\/ / /_\\ \\ | ___/| | \r\n| |___\\ \\____ / | \\| | | | \r\n|_______ \\\\______ /______\\____|__ /|____| |___| \r\n \\/ \\//_____/ \\/ \r\n "); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Starting up.."); if (configOverrideModServer.Value) { ModdedServer.SetServerModdedOnly(); } Harmony val = new Harmony("ModAPI"); MethodInfo methodInfo = AccessTools.Method(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyCreated", (Type[])null, (Type[])null); AccessTools.Method(typeof(GameNetworkManager), "LobbyDataIsJoinable", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ServerPatch), "OnLobbyCreate", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(MenuManager), "Awake", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(ServerPatch), "CacheMenuManager", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null); MethodInfo methodInfo6 = AccessTools.Method(typeof(ServerPatch), "ChatInterpreter", (Type[])null, (Type[])null); val.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Networking.GetString = (Action<string, string>)Delegate.Combine(Networking.GetString, new Action<string, string>(CheatDatabase.CDNetGetString)); Networking.GetListString = (Action<List<string>, string>)Delegate.Combine(Networking.GetListString, new Action<List<string>, string>(Networking.LCAPI_NET_SYNCVAR_SET)); } internal void Start() { Initialize(); } internal void OnDestroy() { Initialize(); } internal void Initialize() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (!Initialized) { Initialized = true; if (!configDisableBundleLoader.Value) { BundleLoader.Load(configLegacyAssetLoading.Value); } GameObject val = new GameObject("API"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<LC_APIManager>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LC_API Started!"); CheatDatabase.RunLocalCheatDetector(); } } internal static void PatchMethodManual(MethodInfo method, MethodInfo patch, Harmony harmony) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony.Patch((MethodBase)method, new HarmonyMethod(patch), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LC_API"; public const string PLUGIN_NAME = "LC_API"; public const string PLUGIN_VERSION = "2.1.1"; } } namespace LC_API.ServerAPI { public static class ModdedServer { private static bool moddedOnly; [Obsolete("Use SetServerModdedOnly() instead. This will be removed/private in a future update.")] public static bool setModdedOnly; public static bool ModdedOnly => moddedOnly; public static void SetServerModdedOnly() { moddedOnly = true; Plugin.Log.LogMessage((object)"A plugin has set your game to only allow you to play with other people who have mods!"); } public static void OnSceneLoaded() { if (Object.op_Implicit((Object)(object)GameNetworkManager.Instance) && ModdedOnly) { GameNetworkManager instance = GameNetworkManager.Instance; instance.gameVersionNum += 16440; setModdedOnly = true; } } } public static class Networking { public static Action<string, string> GetString = delegate { }; public static Action<List<string>, string> GetListString = delegate { }; public static Action<int, string> GetInt = delegate { }; public static Action<float, string> GetFloat = delegate { }; public static Action<Vector3, string> GetVector3 = delegate { }; private static Dictionary<string, string> syncStringVars = new Dictionary<string, string>(); public static void Broadcast(string data, string signature) { if (data.Contains("/")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )"); return; } HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDstring.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(List<string> data, string signature) { string text = ""; foreach (string datum in data) { if (datum.Contains("/")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( / )"); return; } if (datum.Contains("\n")) { Plugin.Log.LogError((object)"Invalid character in broadcasted string event! ( NewLine )"); return; } text = text + datum + "\n"; } HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data?.ToString() + "/" + signature + "/" + NetworkBroadcastDataType.BDlistString.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(int data, string signature) { HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDint.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(float data, string signature) { HUDManager.Instance.AddTextToChatOnServer("<size=0>NWE/" + data + "/" + signature + "/" + NetworkBroadcastDataType.BDfloat.ToString() + "/" + GameNetworkManager.Instance.localPlayerController.playerClientId + "/</size>", -1); } public static void Broadcast(Vector3 data, string signature) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; string[] obj = new string[9] { "<size=0>NWE/", null, null, null, null, null, null, null, null }; Vector3 val = data; obj[1] = ((object)(Vector3)(ref val)).ToString(); obj[2] = "/"; obj[3] = signature; obj[4] = "/"; obj[5] = NetworkBroadcastDataType.BDvector3.ToString(); obj[6] = "/"; obj[7] = GameNetworkManager.Instance.localPlayerController.playerClientId.ToString(); obj[8] = "/</size>"; instance.AddTextToChatOnServer(string.Concat(obj), -1); } public static void RegisterSyncVariable(string name) { if (!syncStringVars.ContainsKey(name)) { syncStringVars.Add(name, ""); } else { Plugin.Log.LogError((object)("Cannot register Sync Variable! A Sync Variable has already been registered with name " + name)); } } public static void SetSyncVariable(string name, string value) { if (syncStringVars.ContainsKey(name)) { syncStringVars[name] = value; Broadcast(new List<string> { name, value }, "LCAPI_NET_SYNCVAR_SET"); } else { Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!")); } } private static void SetSyncVariableB(string name, string value) { if (syncStringVars.ContainsKey(name)) { syncStringVars[name] = value; } else { Plugin.Log.LogError((object)("Cannot set the value of Sync Variable " + name + " as it is not registered!")); } } internal static void LCAPI_NET_SYNCVAR_SET(List<string> list, string arg2) { if (arg2 == "LCAPI_NET_SYNCVAR_SET") { SetSyncVariableB(list[0], list[1]); } } public static string GetSyncVariable(string name) { if (syncStringVars.ContainsKey(name)) { return syncStringVars[name]; } Plugin.Log.LogError((object)("Cannot get the value of Sync Variable " + name + " as it is not registered!")); return ""; } private static void GotString(string data, string signature) { } private static void GotInt(int data, string signature) { } private static void GotFloat(float data, string signature) { } private static void GotVector3(Vector3 data, string signature) { } } } namespace LC_API.ManualPatches { internal static class ServerPatch { internal static bool OnLobbyCreate(GameNetworkManager __instance, Result result, Lobby lobby) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)result != 1) { Debug.LogError((object)$"Lobby could not be created! {result}", (Object)(object)__instance); } __instance.lobbyHostSettings.lobbyName = "[MODDED]" + __instance.lobbyHostSettings.lobbyName.ToString(); Plugin.Log.LogMessage((object)"server pre-setup success"); return true; } internal static bool CacheMenuManager(MenuManager __instance) { LC_APIManager.MenuManager = __instance; return true; } internal static bool ChatInterpreter(HUDManager __instance, string chatMessage) { //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) if (!chatMessage.Contains("NWE") || !chatMessage.Contains("<size=0>")) { return true; } string[] array = chatMessage.Split(new char[1] { '/' }); if (array.Length < 5) { if (array.Length >= 3) { if (!int.TryParse(array[4], out var result)) { Plugin.Log.LogWarning((object)"Failed to parse player ID!!"); return false; } if ((result == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) & !LC_APIManager.netTester) { return false; } Enum.TryParse<NetworkBroadcastDataType>(array[3], out var result2); switch (result2) { case NetworkBroadcastDataType.BDstring: Networking.GetString(array[1], array[2]); break; case NetworkBroadcastDataType.BDint: Networking.GetInt(int.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDfloat: Networking.GetFloat(float.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDvector3: { string[] array2 = array[1].Replace("(", "").Replace(")", "").Split(new char[1] { ',' }); Vector3 arg = default(Vector3); if (array2.Length == 3) { if (float.TryParse(array2[0], out var result3) && float.TryParse(array2[1], out var result4) && float.TryParse(array2[2], out var result5)) { arg.x = result3; arg.y = result4; arg.z = result5; } else { Plugin.Log.LogError((object)"Vector3 Network receive fail. This is a failure of the API, and it should be reported as a bug."); } } else { Plugin.Log.LogError((object)"Vector3 Network receive fail. This is a failure of the API, and it should be reported as a bug."); } Networking.GetVector3(arg, array[2]); break; } case NetworkBroadcastDataType.BDlistString: { string[] source = array[1].Split(new char[1] { '\n' }); Networking.GetListString(source.ToList(), array[2]); break; } } _ = LC_APIManager.netTester; return false; } Plugin.Log.LogError((object)"Generic Network receive fail. This is a failure of the API, and it should be reported as a bug."); Plugin.Log.LogError((object)$"Generic Network receive fail (expected 5+ data fragments, got {array.Length}). This is a failure of the API, and it should be reported as a bug."); return true; } if (!int.TryParse(array[4], out var result6)) { Plugin.Log.LogWarning((object)("Failed to parse player ID '" + array[4] + "'!!")); return false; } if ((result6 == (int)GameNetworkManager.Instance.localPlayerController.playerClientId) & !LC_APIManager.netTester) { return false; } if (!Enum.TryParse<NetworkBroadcastDataType>(array[3], out var result7)) { Plugin.Log.LogError((object)("Unknown datatype - unable to parse '" + array[3] + "' into a known data type!")); return false; } switch (result7) { case NetworkBroadcastDataType.BDstring: Networking.GetString.InvokeActionSafe(array[1], array[2]); break; case NetworkBroadcastDataType.BDint: Networking.GetInt.InvokeActionSafe(int.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDfloat: Networking.GetFloat.InvokeActionSafe(float.Parse(array[1]), array[2]); break; case NetworkBroadcastDataType.BDvector3: { string text = array[1].Trim('(', ')'); string[] array3 = text.Split(new char[1] { ',' }); Vector3 param = default(Vector3); float result8; float result9; float result10; if (array3.Length != 3) { Plugin.Log.LogError((object)$"Vector3 Network receive fail (expected 3 numbers, got {array3.Length} number(?)(s) instead). This is a failure of the API, and it should be reported as a bug. (passing an empty Vector3 in its place)"); } else if (float.TryParse(array3[0], out result8) && float.TryParse(array3[1], out result9) && float.TryParse(array3[2], out result10)) { param.x = result8; param.y = result9; param.z = result10; } else { Plugin.Log.LogError((object)("Vector3 Network receive fail (failed to parse '" + text + "' as numbers). This is a failure of the API, and it should be reported as a bug.")); } Networking.GetVector3.InvokeActionSafe(param, array[2]); break; } } _ = LC_APIManager.netTester; return false; } internal static bool ChatCommands(HUDManager __instance, CallbackContext context) { if (__instance.chatTextField.text.ToLower().Contains("/modcheck")) { CheatDatabase.OtherPlayerCheatDetector(); return false; } return true; } } } namespace LC_API.GameInterfaceAPI { public static class GameState { private static readonly Action NothingAction = delegate { }; public static int AlivePlayerCount { get; private set; } public static ShipState ShipState { get; private set; } public static event Action PlayerDied; public static event Action LandOnMoon; public static event Action WentIntoOrbit; public static event Action ShipStartedLeaving; internal static void GSUpdate() { if (!((Object)(object)StartOfRound.Instance == (Object)null)) { if (StartOfRound.Instance.shipHasLanded && ShipState != ShipState.OnMoon) { ShipState = ShipState.OnMoon; GameState.LandOnMoon.InvokeActionSafe(); } if (StartOfRound.Instance.inShipPhase && ShipState != 0) { ShipState = ShipState.InOrbit; GameState.WentIntoOrbit.InvokeActionSafe(); } if (StartOfRound.Instance.shipIsLeaving && ShipState != ShipState.LeavingMoon) { ShipState = ShipState.LeavingMoon; GameState.ShipStartedLeaving.InvokeActionSafe(); } if (AlivePlayerCount < StartOfRound.Instance.livingPlayers) { GameState.PlayerDied.InvokeActionSafe(); } AlivePlayerCount = StartOfRound.Instance.livingPlayers; } } static GameState() { GameState.PlayerDied = NothingAction; GameState.LandOnMoon = NothingAction; GameState.WentIntoOrbit = NothingAction; GameState.ShipStartedLeaving = NothingAction; } } public class GameTips { private static List<string> tipHeaders = new List<string>(); private static List<string> tipBodys = new List<string>(); private static float lastMessageTime; public static void ShowTip(string header, string body) { tipHeaders.Add(header); tipBodys.Add(body); } public static void UpdateInternal() { lastMessageTime -= Time.deltaTime; if ((tipHeaders.Count > 0) & (lastMessageTime < 0f)) { lastMessageTime = 5f; if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip(tipHeaders[0], tipBodys[0], false, false, "LC_Tip1"); } tipHeaders.RemoveAt(0); tipBodys.RemoveAt(0); } } } } namespace LC_API.Extensions { public static class DelegateExtensions { private static readonly PropertyInfo PluginGetLogger = AccessTools.Property(typeof(BaseUnityPlugin), "Logger"); public static void InvokeActionSafe(this Action action) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action)@delegate)(); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } public static void InvokeActionSafe<T>(this Action<T> action, T param) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action<T>)@delegate)(param); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } public static void InvokeActionSafe<T1, T2>(this Action<T1, T2> action, T1 param1, T2 param2) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((Action<T1, T2>)@delegate)(param1, param2); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } internal static void InvokeParameterlessDelegate<T>(this T paramlessDelegate) where T : Delegate { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if ((Delegate?)paramlessDelegate == (Delegate?)null) { return; } Delegate[] invocationList = paramlessDelegate.GetInvocationList(); foreach (Delegate @delegate in invocationList) { try { ((T)@delegate).DynamicInvoke(); } catch (Exception ex) { Plugin.Log.LogError((object)"Exception while invoking hook callback!"); string asmName = @delegate.GetMethodInfo().DeclaringType.Assembly.FullName; PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo pi) => ((object)pi.Instance).GetType().Assembly.FullName == asmName)); if (val == null) { Plugin.Log.LogError((object)ex.ToString()); break; } ((ManualLogSource)PluginGetLogger.GetValue(val.Instance)).LogError((object)ex.ToString()); } } } } } namespace LC_API.Data { internal enum NetworkBroadcastDataType { Unknown, BDint, BDfloat, BDvector3, BDstring, BDlistString } public enum ShipState { InOrbit, OnMoon, LeavingMoon } } namespace LC_API.Comp { internal class LC_APIManager : MonoBehaviour { public static MenuManager MenuManager; public static bool netTester; private static int playerCount; private static bool wanttoCheckMods; private static float lobbychecktimer; public void Update() { GameState.GSUpdate(); GameTips.UpdateInternal(); if ((((Object)(object)HUDManager.Instance != (Object)null) & netTester) && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { Networking.Broadcast("testerData", "testerSignature"); } if (!ModdedServer.setModdedOnly) { ModdedServer.OnSceneLoaded(); } else if (ModdedServer.ModdedOnly && (Object)(object)MenuManager != (Object)null && Object.op_Implicit((Object)(object)MenuManager.versionNumberText)) { ((TMP_Text)MenuManager.versionNumberText).text = $"v{GameNetworkManager.Instance.gameVersionNum - 16440}\nMOD"; } if ((Object)(object)GameNetworkManager.Instance != (Object)null) { if (playerCount < GameNetworkManager.Instance.connectedPlayers) { lobbychecktimer = -4.5f; wanttoCheckMods = true; } playerCount = GameNetworkManager.Instance.connectedPlayers; } if (lobbychecktimer < 0f) { lobbychecktimer += Time.deltaTime; } else if (wanttoCheckMods) { wanttoCheckMods = false; CD(); } } private void CD() { CheatDatabase.OtherPlayerCheatDetector(); } } } namespace LC_API.BundleAPI { public static class BundleLoader { [Obsolete("Use OnLoadedBundles instead. This will be removed/private in a future update.")] public delegate void OnLoadedAssetsDelegate(); [Obsolete("Use GetLoadedAsset instead. This will be removed/private in a future update.")] public static ConcurrentDictionary<string, Object> assets = new ConcurrentDictionary<string, Object>(); [Obsolete("Use OnLoadedBundles instead. This will be removed/private in a future update.")] public static OnLoadedAssetsDelegate OnLoadedAssets = LoadAssetsCompleted; public static bool AssetsInLegacyDirectory { get; private set; } public static bool LegacyLoadingEnabled { get; private set; } public static event Action OnLoadedBundles; internal static void Load(bool legacyLoading) { LegacyLoadingEnabled = legacyLoading; Plugin.Log.LogMessage((object)"BundleAPI will now load all asset bundles..."); string path = Path.Combine(Paths.BepInExRootPath, "Bundles"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); Plugin.Log.LogMessage((object)"BundleAPI Created legacy bundle directory in BepInEx/Bundles"); } string[] array = (from x in Directory.GetFiles(path, "*", SearchOption.AllDirectories) where !x.EndsWith(".manifest", StringComparison.CurrentCultureIgnoreCase) select x).ToArray(); AssetsInLegacyDirectory = array.Length != 0; if (!AssetsInLegacyDirectory) { Plugin.Log.LogMessage((object)"BundleAPI got no assets to load from legacy directory"); } if (AssetsInLegacyDirectory) { Plugin.Log.LogWarning((object)"The path BepInEx > Bundles is outdated and should not be used anymore! Bundles will be loaded from BepInEx > plugins from now on"); LoadAllAssetsFromDirectory(array, legacyLoading); } path = Path.Combine(Paths.BepInExRootPath, "plugins"); array = (from x in Directory.GetFiles(path, "*", SearchOption.AllDirectories) where !x.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase) where !x.EndsWith(".json", StringComparison.CurrentCultureIgnoreCase) where !x.EndsWith(".png", StringComparison.CurrentCultureIgnoreCase) where !x.EndsWith(".md", StringComparison.CurrentCultureIgnoreCase) where !x.EndsWith(".old", StringComparison.CurrentCultureIgnoreCase) where !x.EndsWith(".txt", StringComparison.CurrentCultureIgnoreCase) select x).ToArray(); if (array.Length == 0) { Plugin.Log.LogMessage((object)"BundleAPI got no assets to load from plugins folder"); } else { LoadAllAssetsFromDirectory(array, legacyLoading); } OnLoadedAssets.InvokeParameterlessDelegate(); BundleLoader.OnLoadedBundles.InvokeActionSafe(); } private static void LoadAllAssetsFromDirectory(string[] array, bool legacyLoading) { if (legacyLoading) { Plugin.Log.LogMessage((object)("BundleAPI got " + array.Length + " AssetBundles to load!")); for (int i = 0; i < array.Length; i++) { try { SaveAsset(array[i], legacyLoading); } catch (Exception) { Plugin.Log.LogError((object)("Failed to load an assetbundle! Path: " + array[i])); } } return; } Plugin.Log.LogMessage((object)("BundleAPI got " + array.Length + " AssetBundles to load!")); for (int j = 0; j < array.Length; j++) { try { SaveAsset(array[j], legacyLoading); } catch (Exception) { Plugin.Log.LogError((object)("Failed to load an assetbundle! Path: " + array[j])); } } } public static void SaveAsset(string path, bool legacyLoad) { AssetBundle val = AssetBundle.LoadFromFile(path); try { string[] allAssetNames = val.GetAllAssetNames(); foreach (string text in allAssetNames) { Plugin.Log.LogMessage((object)("Got asset for load: " + text)); Object val2 = val.LoadAsset(text); if (val2 == (Object)null) { Plugin.Log.LogWarning((object)$"Skipped/failed loading an asset (from bundle '{((Object)val).name}') - Asset path: {val2}"); continue; } string key = (legacyLoad ? text.ToUpper() : text.ToLower()); if (assets.ContainsKey(key)) { Plugin.Log.LogError((object)"BundleAPI got duplicate asset!"); break; } assets.TryAdd(key, val2); Plugin.Log.LogMessage((object)("Loaded asset: " + val2.name)); } } finally { if (val != null) { val.Unload(false); } } } public static TAsset GetLoadedAsset<TAsset>(string itemPath) where TAsset : Object { Object value = null; if (LegacyLoadingEnabled) { assets.TryGetValue(itemPath.ToUpper(), out value); } if (value == (Object)null) { assets.TryGetValue(itemPath.ToLower(), out value); } return (TAsset)(object)value; } private static void LoadAssetsCompleted() { Plugin.Log.LogMessage((object)"BundleAPI finished loading all assets."); } static BundleLoader() { BundleLoader.OnLoadedBundles = LoadAssetsCompleted; } } }
plugins/LC_SoundTool.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.Patches; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LC_SoundTool")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Various audio related functions. Mainly logs all sounds that are playing and what type of playback they're into the BepInEx console.")] [assembly: AssemblyFileVersion("1.2.2.0")] [assembly: AssemblyInformationalVersion("1.2.2")] [assembly: AssemblyProduct("LC_SoundTool")] [assembly: AssemblyTitle("LC_SoundTool")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.2.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 LCSoundTool { public class AudioSourceExtension : MonoBehaviour { public AudioSource audioSource; public bool playOnAwake = false; public bool loop = false; private void Awake() { if (!((Object)(object)audioSource == (Object)null) && !((Object)(object)audioSource.clip == (Object)null) && !audioSource.isPlaying) { if (playOnAwake) { audioSource.Play(); } SoundTool.Instance.logger.LogDebug((object)$"Started playback of {audioSource} with clip {audioSource.clip} in Awake function!"); } } private void Start() { if (!((Object)(object)audioSource == (Object)null) && !((Object)(object)audioSource.clip == (Object)null) && !audioSource.isPlaying) { if (playOnAwake) { audioSource.Play(); } SoundTool.Instance.logger.LogDebug((object)$"Started playback of {audioSource} with clip {audioSource.clip} in Start function!"); } } } [BepInPlugin("LCSoundTool", "LC Sound Tool", "1.2.2")] public class SoundTool : BaseUnityPlugin { private const string PLUGIN_GUID = "LCSoundTool"; private const string PLUGIN_NAME = "LC Sound Tool"; private const string PLUGIN_VERSION = "1.2.2"; private readonly Harmony harmony = new Harmony("LCSoundTool"); public static SoundTool Instance; internal ManualLogSource logger; public KeyboardShortcut toggleAudioSourceDebugLog; public KeyboardShortcut toggleIndepthDebugLog; public bool wasKeyDown; public bool wasKeyDown2; public static bool debugAudioSources; public static bool indepthDebugging; private GameObject soundToolGameObject; public SoundToolUpdater updater { get; private set; } public static Dictionary<string, AudioClip> replacedClips { get; private set; } public static void ReplaceAudioClip(string originalName, AudioClip newClip) { if (string.IsNullOrEmpty(originalName)) { Instance.logger.LogWarning((object)"Plugin LCSoundTool is trying to replace an audio clip without original clip specified! This is not allowed."); } else if ((Object)(object)newClip == (Object)null) { Instance.logger.LogWarning((object)"Plugin LCSoundTool is trying to replace an audio clip without new clip specified! This is not allowed."); } else if (replacedClips.ContainsKey(originalName)) { Instance.logger.LogWarning((object)"Plugin LCSoundTool is trying to replace an audio clip that already has been replaced! This is not allowed."); } else { replacedClips.Add(originalName, newClip); } } public static void ReplaceAudioClip(AudioClip originalClip, AudioClip newClip) { if ((Object)(object)originalClip == (Object)null) { Instance.logger.LogWarning((object)"Plugin LCSoundTool is trying to replace an audio clip without original clip specified! This is not allowed."); } else if ((Object)(object)newClip == (Object)null) { Instance.logger.LogWarning((object)"Plugin LCSoundTool is trying to replace an audio clip without new clip specified! This is not allowed."); } else { ReplaceAudioClip(((Object)originalClip).name, newClip); } } public static void RestoreAudioClip(string name) { if (string.IsNullOrEmpty(name)) { Instance.logger.LogWarning((object)"Plugin LCSoundTool is trying to restore an audio clip without original clip specified! This is not allowed."); } else if (!replacedClips.ContainsKey(name)) { Instance.logger.LogWarning((object)"Plugin LCSoundTool is trying to restore an audio clip that does not exist! This is not allowed."); } else { replacedClips.Remove(name); } } public static void RestoreAudioClip(AudioClip clip) { if ((Object)(object)clip == (Object)null) { Instance.logger.LogWarning((object)"Plugin LCSoundTool is trying to restore an audio clip without original clip specified! This is not allowed."); } else { RestoreAudioClip(((Object)clip).name); } } private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null) { Instance = this; logger = Logger.CreateLogSource("LCSoundTool"); logger.LogInfo((object)"Plugin LCSoundTool is loaded!"); toggleAudioSourceDebugLog = new KeyboardShortcut((KeyCode)286, (KeyCode[])(object)new KeyCode[0]); toggleIndepthDebugLog = new KeyboardShortcut((KeyCode)286, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }); debugAudioSources = false; indepthDebugging = false; replacedClips = new Dictionary<string, AudioClip>(); harmony.PatchAll(typeof(AudioSourcePatch)); harmony.PatchAll(typeof(NetworkSceneManagerPatch)); SoundToolUpdater(); } } private void Update() { SoundToolUpdater(); } private void OnDestroy() { SoundToolUpdater(); } private void SoundToolUpdater() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown if ((Object)(object)soundToolGameObject == (Object)null) { GameObject val = GameObject.Find("SoundToolUpdater"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } soundToolGameObject = new GameObject("SoundToolUpdater"); updater = soundToolGameObject.AddComponent<SoundToolUpdater>(); updater.originSoundTool = this; if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)Instance); Instance = this; } else if ((Object)(object)Instance == (Object)null) { Instance = this; } } } public static AudioClip GetAudioClip(string modFolder, string soundName) { return GetAudioClip(modFolder, string.Empty, soundName); } public static AudioClip GetAudioClip(string modFolder, string subFolder, string soundName) { bool flag = true; string text = " "; string text2 = Path.Combine(Paths.PluginPath, modFolder, subFolder, soundName); string text3 = Path.Combine(Paths.PluginPath, modFolder, soundName); string path = Path.Combine(Paths.PluginPath, modFolder, subFolder); string text4 = Path.Combine(Paths.PluginPath, subFolder, soundName); string path2 = Path.Combine(Paths.PluginPath, subFolder); if (!Directory.Exists(path)) { if (!string.IsNullOrEmpty(subFolder)) { Instance.logger.LogWarning((object)("Requested directory at BepInEx/Plugins/" + modFolder + "/" + subFolder + " does not exist!")); } else { Instance.logger.LogWarning((object)("Requested directory at BepInEx/Plugins/" + modFolder + " does not exist!")); if (!modFolder.Contains("-")) { Instance.logger.LogWarning((object)"This sound mod might not be compatable with mod managers. You should contact the sound mod's author."); } } flag = false; } if (!File.Exists(text2)) { Instance.logger.LogWarning((object)("Requested audio file does not exist at path " + text2 + "!")); flag = false; Instance.logger.LogDebug((object)("Looking for audio file from mod root instead at " + text3 + "...")); if (File.Exists(text3)) { Instance.logger.LogDebug((object)("Found audio file at path " + text3 + "!")); text2 = text3; flag = true; } else { Instance.logger.LogWarning((object)("Requested audio file does not exist at mod root path " + text3 + "!")); } } if (Directory.Exists(path2)) { if (!string.IsNullOrEmpty(subFolder)) { Instance.logger.LogWarning((object)("Legacy directory location at BepInEx/Plugins/" + subFolder + " found!")); } else if (!modFolder.Contains("-")) { Instance.logger.LogWarning((object)"Legacy directory location at BepInEx/Plugins found!"); } } if (File.Exists(text4)) { Instance.logger.LogWarning((object)("Legacy path contains the requested audio file at path " + text4 + "!")); text = " legacy "; text2 = text4; flag = true; } AudioClip val = null; if (flag) { Instance.logger.LogDebug((object)("Loading AudioClip " + soundName + " from" + text + "path: " + text2)); val = LoadClip(text2); Instance.logger.LogDebug((object)$"Finished loading AudioClip {soundName} with length of {val.length}!"); } else { Instance.logger.LogWarning((object)("Failed to load AudioClip " + soundName + " from invalid" + text + "path at " + text2 + "!")); } return val; } private static AudioClip LoadClip(string path) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 AudioClip result = null; UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20); try { audioClip.SendWebRequest(); try { while (!audioClip.isDone) { } if ((int)audioClip.result != 1) { Instance.logger.LogError((object)("Failed to load AudioClip from path: " + path + " Full error: " + audioClip.error)); } else { result = DownloadHandlerAudioClip.GetContent(audioClip); } } catch (Exception ex) { Instance.logger.LogError((object)(ex.Message + ", " + ex.StackTrace)); } } finally { ((IDisposable)audioClip)?.Dispose(); } return result; } } public class SoundToolUpdater : MonoBehaviour { [HideInInspector] public SoundTool originSoundTool; public void Update() { if ((Object)(object)originSoundTool != (Object)null && (Object)(object)originSoundTool != (Object)(object)SoundTool.Instance) { Object.Destroy((Object)(object)((Component)originSoundTool).gameObject); return; } if (((KeyboardShortcut)(ref originSoundTool.toggleIndepthDebugLog)).IsDown() && !originSoundTool.wasKeyDown2) { originSoundTool.wasKeyDown2 = true; originSoundTool.wasKeyDown = false; } if (((KeyboardShortcut)(ref originSoundTool.toggleIndepthDebugLog)).IsUp() && originSoundTool.wasKeyDown2) { originSoundTool.wasKeyDown2 = false; originSoundTool.wasKeyDown = false; SoundTool.debugAudioSources = !SoundTool.debugAudioSources; SoundTool.indepthDebugging = SoundTool.debugAudioSources; SoundTool.Instance.logger.LogDebug((object)$"Toggling in-depth AudioSource debug logs {SoundTool.debugAudioSources}!"); return; } if (!originSoundTool.wasKeyDown2 && !((KeyboardShortcut)(ref originSoundTool.toggleIndepthDebugLog)).IsDown() && ((KeyboardShortcut)(ref originSoundTool.toggleAudioSourceDebugLog)).IsDown() && !originSoundTool.wasKeyDown) { originSoundTool.wasKeyDown = true; originSoundTool.wasKeyDown2 = false; } if (((KeyboardShortcut)(ref originSoundTool.toggleAudioSourceDebugLog)).IsUp() && originSoundTool.wasKeyDown) { originSoundTool.wasKeyDown = false; originSoundTool.wasKeyDown2 = false; SoundTool.debugAudioSources = !SoundTool.debugAudioSources; SoundTool.Instance.logger.LogDebug((object)$"Toggling AudioSource debug logs {SoundTool.debugAudioSources}!"); } } public AudioSource[] GetAllPlayOnAwakeAudioSources() { AudioSource[] array = Object.FindObjectsOfType<AudioSource>(true); List<AudioSource> list = new List<AudioSource>(); for (int i = 0; i < array.Length; i++) { if (array[i].playOnAwake) { list.Add(array[i]); } } return list.ToArray(); } } public static class PluginInfo { public const string PLUGIN_GUID = "LC_SoundTool"; public const string PLUGIN_NAME = "LC_SoundTool"; public const string PLUGIN_VERSION = "1.2.2"; } } namespace LCSoundTool.Patches { [HarmonyPatch(typeof(AudioSource))] internal class AudioSourcePatch { private static Dictionary<string, AudioClip> originalClips = new Dictionary<string, AudioClip>(); [HarmonyPatch("Play", new Type[] { })] [HarmonyPrefix] public static void Play_Patch(AudioSource __instance) { RunDynamicClipReplacement(__instance); DebugPlayMethod(__instance); } [HarmonyPatch("Play", new Type[] { typeof(ulong) })] [HarmonyPrefix] public static void Play_UlongPatch(AudioSource __instance) { RunDynamicClipReplacement(__instance); DebugPlayMethod(__instance); } [HarmonyPatch("Play", new Type[] { typeof(double) })] [HarmonyPrefix] public static void Play_DoublePatch(AudioSource __instance) { RunDynamicClipReplacement(__instance); DebugPlayMethod(__instance); } [HarmonyPatch("PlayDelayed", new Type[] { typeof(float) })] [HarmonyPrefix] public static void PlayDelayed_Patch(AudioSource __instance) { RunDynamicClipReplacement(__instance); DebugPlayDelayedMethod(__instance); } [HarmonyPatch("PlayClipAtPoint", new Type[] { typeof(AudioClip), typeof(Vector3), typeof(float) })] [HarmonyPrefix] public static bool PlayClipAtPoint_Patch(AudioClip clip, Vector3 position, float volume) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("One shot audio"); val.transform.position = position; AudioSource val2 = val.AddComponent<AudioSource>(); val2.clip = clip; val2.spatialBlend = 1f; val2.volume = volume; RunDynamicClipReplacement(val2); val2.Play(); DebugPlayClipAtPointMethod(val2, position); Object.Destroy((Object)(object)val, clip.length * ((Time.timeScale < 0.01f) ? 0.01f : Time.timeScale)); return false; } [HarmonyPatch("PlayOneShotHelper", new Type[] { typeof(AudioSource), typeof(AudioClip), typeof(float) })] [HarmonyPrefix] public static void PlayOneShotHelper_Patch(AudioSource source, ref AudioClip clip, float volumeScale) { clip = ReplaceClipWithNew(clip); DebugPlayOneShotMethod(source, clip); } private static void DebugPlayMethod(AudioSource instance) { if (SoundTool.debugAudioSources && !SoundTool.indepthDebugging && (Object)(object)instance != (Object)null) { SoundTool.Instance.logger.LogDebug((object)$"{instance} at {((Component)instance).transform.root} is playing {((Object)instance.clip).name}"); } else if (SoundTool.indepthDebugging && (Object)(object)instance != (Object)null) { SoundTool.Instance.logger.LogDebug((object)$"{instance} is playing {((Object)instance.clip).name} at"); Transform val = ((Component)instance).transform; while ((Object)(object)val.parent != (Object)null || (Object)(object)val != (Object)(object)((Component)instance).transform.root) { SoundTool.Instance.logger.LogDebug((object)$"--- {val.parent}"); val = val.parent; } if ((Object)(object)val == (Object)(object)((Component)instance).transform.root) { SoundTool.Instance.logger.LogDebug((object)$"--- {((Component)instance).transform.root}"); } } } private static void DebugPlayDelayedMethod(AudioSource instance) { if (SoundTool.debugAudioSources && !SoundTool.indepthDebugging && (Object)(object)instance != (Object)null) { SoundTool.Instance.logger.LogDebug((object)$"{instance} at {((Component)instance).transform.root} is playing {((Object)instance.clip).name} with delay"); } else if (SoundTool.indepthDebugging && (Object)(object)instance != (Object)null) { SoundTool.Instance.logger.LogDebug((object)$"{instance} is playing {((Object)instance.clip).name} with delay at"); Transform val = ((Component)instance).transform; while ((Object)(object)val.parent != (Object)null || (Object)(object)val != (Object)(object)((Component)instance).transform.root) { SoundTool.Instance.logger.LogDebug((object)$"--- {val.parent}"); val = val.parent; } if ((Object)(object)val == (Object)(object)((Component)instance).transform.root) { SoundTool.Instance.logger.LogDebug((object)$"--- {((Component)instance).transform.root}"); } } } private static void DebugPlayClipAtPointMethod(AudioSource audioSource, Vector3 position) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (SoundTool.debugAudioSources && !SoundTool.indepthDebugging && (Object)(object)audioSource != (Object)null) { SoundTool.Instance.logger.LogDebug((object)$"{audioSource} at {((Component)audioSource).transform.root} is playing {((Object)audioSource.clip).name} at point {position}"); } else if (SoundTool.indepthDebugging && (Object)(object)audioSource != (Object)null) { SoundTool.Instance.logger.LogDebug((object)$"{audioSource} is playing {((Object)audioSource.clip).name} located at point {position} within "); Transform val = ((Component)audioSource).transform; while ((Object)(object)val.parent != (Object)null || (Object)(object)val != (Object)(object)((Component)audioSource).transform.root) { SoundTool.Instance.logger.LogDebug((object)$"--- {val.parent}"); val = val.parent; } if ((Object)(object)val == (Object)(object)((Component)audioSource).transform.root) { SoundTool.Instance.logger.LogDebug((object)$"--- {((Component)audioSource).transform.root}"); } } } private static void DebugPlayOneShotMethod(AudioSource source, AudioClip clip) { if (SoundTool.debugAudioSources && !SoundTool.indepthDebugging && (Object)(object)source != (Object)null) { SoundTool.Instance.logger.LogDebug((object)$"{source} at {((Component)source).transform.root} is playing one shot {((Object)clip).name}"); } else if (SoundTool.indepthDebugging && (Object)(object)source != (Object)null) { SoundTool.Instance.logger.LogDebug((object)$"{source} is playing one shot {((Object)clip).name} at"); Transform val = ((Component)source).transform; while ((Object)(object)val.parent != (Object)null || (Object)(object)val != (Object)(object)((Component)source).transform.root) { SoundTool.Instance.logger.LogDebug((object)$"--- {val.parent}"); val = val.parent; } if ((Object)(object)val == (Object)(object)((Component)source).transform.root) { SoundTool.Instance.logger.LogDebug((object)$"--- {((Component)source).transform.root}"); } } } private static void RunDynamicClipReplacement(AudioSource instance) { if ((Object)(object)instance == (Object)null || (Object)(object)instance.clip == (Object)null) { return; } string name = instance.clip.GetName(); if (SoundTool.replacedClips.ContainsKey(name)) { if (!originalClips.ContainsKey(name)) { originalClips.Add(name, instance.clip); } instance.clip = SoundTool.replacedClips[name]; } else if (originalClips.ContainsKey(name)) { instance.clip = originalClips[name]; originalClips.Remove(name); } } private static AudioClip ReplaceClipWithNew(AudioClip original) { if ((Object)(object)original == (Object)null) { return original; } string name = original.GetName(); if (SoundTool.replacedClips.ContainsKey(name)) { if (!originalClips.ContainsKey(name)) { originalClips.Add(name, original); } return SoundTool.replacedClips[name]; } if (originalClips.ContainsKey(name)) { AudioClip result = originalClips[name]; originalClips.Remove(name); return result; } return original; } } [HarmonyPatch(typeof(NetworkSceneManager))] internal class NetworkSceneManagerPatch { [HarmonyPatch("OnSceneLoaded")] [HarmonyPostfix] public static void OnSceneLoaded_Patch() { if ((Object)(object)SoundTool.Instance.updater == (Object)null) { return; } SoundTool.Instance.logger.LogDebug((object)"Grabbing all playOnAwake AudioSources..."); AudioSource[] allPlayOnAwakeAudioSources = SoundTool.Instance.updater.GetAllPlayOnAwakeAudioSources(); SoundTool.Instance.logger.LogDebug((object)$"Found {allPlayOnAwakeAudioSources.Length} playOnAwake AudioSources!"); SoundTool.Instance.logger.LogDebug((object)$"Starting setup on {allPlayOnAwakeAudioSources.Length - 3} compatable playOnAwake AudioSources..."); AudioSource[] array = allPlayOnAwakeAudioSources; AudioSourceExtension audioSourceExtension = default(AudioSourceExtension); foreach (AudioSource val in array) { if (!((Object)val).name.Contains("ThrusterCloseAudio") && !((Object)val).name.Contains("ThrusterAmbientAudio") && !((Object)val).name.Contains("Ship3dSFX")) { if (((Component)((Component)val).transform).TryGetComponent<AudioSourceExtension>(ref audioSourceExtension)) { audioSourceExtension.playOnAwake = true; audioSourceExtension.audioSource = val; audioSourceExtension.loop = val.loop; val.playOnAwake = false; SoundTool.Instance.logger.LogDebug((object)$"-Set- {Array.IndexOf(allPlayOnAwakeAudioSources, val) + 1} {val} done!"); } else { AudioSourceExtension audioSourceExtension2 = ((Component)val).gameObject.AddComponent<AudioSourceExtension>(); audioSourceExtension2.audioSource = val; audioSourceExtension2.playOnAwake = true; audioSourceExtension2.loop = val.loop; val.playOnAwake = false; SoundTool.Instance.logger.LogDebug((object)$"-Add- {Array.IndexOf(allPlayOnAwakeAudioSources, val) + 1} {val} done!"); } } } SoundTool.Instance.logger.LogDebug((object)$"Done setting up {allPlayOnAwakeAudioSources.Length - 3} compatable playOnAwake AudioSources!"); } } }
plugins/LethalLib/LethalLib.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.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using DunGen; using DunGen.Graph; using LethalLib.Extras; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalLib")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Mod for Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+60d42612d19dbe329175a80dfc41bc601a0ec3eb")] [assembly: AssemblyProduct("LethalLib")] [assembly: AssemblyTitle("LethalLib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] internal class <Module> { static <Module>() { } } 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 LethalLib { [BepInPlugin("evaisa.lethallib", "LethalLib", "0.9.0")] public class Plugin : BaseUnityPlugin { public const string ModGUID = "evaisa.lethallib"; public const string ModName = "LethalLib"; public const string ModVersion = "0.9.0"; public static AssetBundle MainAssets; public static ManualLogSource logger; private void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) logger = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalLib loaded!!"); new ILHook((MethodBase)typeof(StackTrace).GetMethod("AddFrames", BindingFlags.Instance | BindingFlags.NonPublic), new Manipulator(IlHook)); Enemies.Init(); Items.Init(); Unlockables.Init(); MapObjects.Init(); Dungeon.Init(); Weathers.Init(); NetworkPrefabs.Init(); } private void IlHook(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)typeof(StackFrame).GetMethod("GetFileLineNumber", BindingFlags.Instance | BindingFlags.Public)) }); val.RemoveRange(2); val.EmitDelegate<Func<StackFrame, string>>((Func<StackFrame, string>)GetLineOrIL); } private static string GetLineOrIL(StackFrame instance) { int fileLineNumber = instance.GetFileLineNumber(); if (fileLineNumber == -1 || fileLineNumber == 0) { return "IL_" + instance.GetILOffset().ToString("X4"); } return fileLineNumber.ToString(); } } } namespace LethalLib.Modules { public class Dungeon { public class CustomDungeonArchetype { public DungeonArchetype archeType; public Levels.LevelTypes LevelTypes; public int lineIndex = -1; } public class CustomGraphLine { public GraphLine graphLine; public Levels.LevelTypes LevelTypes; } public class CustomDungeon { public int rarity; public DungeonFlow dungeonFlow; public Levels.LevelTypes LevelTypes; public string[] levelOverrides; public int dungeonIndex = -1; public AudioClip firstTimeDungeonAudio; } [CompilerGenerated] private static class <>O { public static hook_GenerateNewFloor <0>__RoundManager_GenerateNewFloor; public static hook_Start <1>__RoundManager_Start; public static hook_Start <2>__StartOfRound_Start; } public static List<CustomDungeonArchetype> customDungeonArchetypes = new List<CustomDungeonArchetype>(); public static List<CustomGraphLine> customGraphLines = new List<CustomGraphLine>(); public static Dictionary<string, TileSet> extraTileSets = new Dictionary<string, TileSet>(); public static Dictionary<string, GameObjectChance> extraRooms = new Dictionary<string, GameObjectChance>(); public static List<CustomDungeon> customDungeons = new List<CustomDungeon>(); public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown object obj = <>O.<0>__RoundManager_GenerateNewFloor; if (obj == null) { hook_GenerateNewFloor val = RoundManager_GenerateNewFloor; <>O.<0>__RoundManager_GenerateNewFloor = val; obj = (object)val; } RoundManager.GenerateNewFloor += (hook_GenerateNewFloor)obj; object obj2 = <>O.<1>__RoundManager_Start; if (obj2 == null) { hook_Start val2 = RoundManager_Start; <>O.<1>__RoundManager_Start = val2; obj2 = (object)val2; } RoundManager.Start += (hook_Start)obj2; object obj3 = <>O.<2>__StartOfRound_Start; if (obj3 == null) { hook_Start val3 = StartOfRound_Start; <>O.<2>__StartOfRound_Start = val3; obj3 = (object)val3; } StartOfRound.Start += (hook_Start)obj3; } private static void StartOfRound_Start(orig_Start orig, StartOfRound self) { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown foreach (CustomDungeon dungeon in customDungeons) { SelectableLevel[] levels = self.levels; foreach (SelectableLevel val in levels) { string name = ((Object)val).name; bool flag = dungeon.LevelTypes.HasFlag(Levels.LevelTypes.All) || (dungeon.levelOverrides != null && dungeon.levelOverrides.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant())); if (Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag) { Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name))); if ((flag || dungeon.LevelTypes.HasFlag(levelTypes)) && !val.dungeonFlowTypes.Any((IntWithRarity rarityInt) => rarityInt.id == dungeon.dungeonIndex)) { List<IntWithRarity> list = val.dungeonFlowTypes.ToList(); list.Add(new IntWithRarity { id = dungeon.dungeonIndex, rarity = dungeon.rarity }); val.dungeonFlowTypes = list.ToArray(); } } } } Plugin.logger.LogInfo((object)"Added custom dungeons to levels"); orig.Invoke(self); } private static void RoundManager_Start(orig_Start orig, RoundManager self) { foreach (CustomDungeon customDungeon in customDungeons) { if (self.dungeonFlowTypes.Contains(customDungeon.dungeonFlow)) { continue; } List<DungeonFlow> list = self.dungeonFlowTypes.ToList(); list.Add(customDungeon.dungeonFlow); self.dungeonFlowTypes = list.ToArray(); int dungeonIndex = self.dungeonFlowTypes.Length - 1; customDungeon.dungeonIndex = dungeonIndex; List<AudioClip> list2 = self.firstTimeDungeonAudios.ToList(); if (list2.Count != self.dungeonFlowTypes.Length - 1) { while (list2.Count < self.dungeonFlowTypes.Length - 1) { list2.Add(null); } } list2.Add(customDungeon.firstTimeDungeonAudio); self.firstTimeDungeonAudios = list2.ToArray(); } orig.Invoke(self); } private static void RoundManager_GenerateNewFloor(orig_GenerateNewFloor orig, RoundManager self) { string name = ((Object)self.currentLevel).name; if (Enum.IsDefined(typeof(Levels.LevelTypes), name)) { Levels.LevelTypes levelEnum = (Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name); int index = 0; self.dungeonGenerator.Generator.DungeonFlow.Lines.ForEach(delegate(GraphLine line) { foreach (CustomDungeonArchetype customDungeonArchetype in customDungeonArchetypes) { if (customDungeonArchetype.LevelTypes.HasFlag(levelEnum) && !line.DungeonArchetypes.Contains(customDungeonArchetype.archeType) && (customDungeonArchetype.lineIndex == -1 || customDungeonArchetype.lineIndex == index)) { line.DungeonArchetypes.Add(customDungeonArchetype.archeType); Plugin.logger.LogInfo((object)("Added " + ((Object)customDungeonArchetype.archeType).name + " to " + name)); } } foreach (DungeonArchetype dungeonArchetype in line.DungeonArchetypes) { string name2 = ((Object)dungeonArchetype).name; if (extraTileSets.ContainsKey(name2)) { TileSet val4 = extraTileSets[name2]; if (!dungeonArchetype.TileSets.Contains(val4)) { dungeonArchetype.TileSets.Add(val4); Plugin.logger.LogInfo((object)("Added " + ((Object)val4).name + " to " + name)); } } foreach (TileSet tileSet in dungeonArchetype.TileSets) { string name3 = ((Object)tileSet).name; if (extraRooms.ContainsKey(name3)) { GameObjectChance item = extraRooms[name3]; if (!tileSet.TileWeights.Weights.Contains(item)) { tileSet.TileWeights.Weights.Add(item); } } } } index++; }); foreach (CustomGraphLine customGraphLine in customGraphLines) { if (customGraphLine.LevelTypes.HasFlag(levelEnum) && !self.dungeonGenerator.Generator.DungeonFlow.Lines.Contains(customGraphLine.graphLine)) { self.dungeonGenerator.Generator.DungeonFlow.Lines.Add(customGraphLine.graphLine); } } } orig.Invoke(self); NetworkManager val = Object.FindObjectOfType<NetworkManager>(); RandomMapObject[] array = Object.FindObjectsOfType<RandomMapObject>(); RandomMapObject[] array2 = array; foreach (RandomMapObject val2 in array2) { for (int j = 0; j < val2.spawnablePrefabs.Count; j++) { string prefabName = ((Object)val2.spawnablePrefabs[j]).name; NetworkPrefab val3 = val.NetworkConfig.Prefabs.m_Prefabs.First((NetworkPrefab x) => ((Object)x.Prefab).name == prefabName); if (val3 != null && (Object)(object)val3.Prefab != (Object)(object)val2.spawnablePrefabs[j]) { val2.spawnablePrefabs[j] = val3.Prefab; } } } } public static void AddArchetype(DungeonArchetype archetype, Levels.LevelTypes levelFlags, int lineIndex = -1) { CustomDungeonArchetype customDungeonArchetype = new CustomDungeonArchetype(); customDungeonArchetype.archeType = archetype; customDungeonArchetype.LevelTypes = levelFlags; customDungeonArchetype.lineIndex = lineIndex; customDungeonArchetypes.Add(customDungeonArchetype); } public static void AddLine(GraphLine line, Levels.LevelTypes levelFlags) { CustomGraphLine customGraphLine = new CustomGraphLine(); customGraphLine.graphLine = line; customGraphLine.LevelTypes = levelFlags; customGraphLines.Add(customGraphLine); } public static void AddLine(DungeonGraphLineDef line, Levels.LevelTypes levelFlags) { AddLine(line.graphLine, levelFlags); } public static void AddTileSet(TileSet set, string archetypeName) { extraTileSets.Add(archetypeName, set); } public static void AddRoom(GameObjectChance room, string tileSetName) { extraRooms.Add(tileSetName, room); } public static void AddRoom(GameObjectChanceDef room, string tileSetName) { AddRoom(room.gameObjectChance, tileSetName); } public static void AddDungeon(DungeonDef dungeon, Levels.LevelTypes levelFlags) { AddDungeon(dungeon.dungeonFlow, dungeon.rarity, levelFlags, dungeon.firstTimeDungeonAudio); } public static void AddDungeon(DungeonDef dungeon, Levels.LevelTypes levelFlags, string[] levelOverrides) { AddDungeon(dungeon.dungeonFlow, dungeon.rarity, levelFlags, levelOverrides, dungeon.firstTimeDungeonAudio); } public static void AddDungeon(DungeonFlow dungeon, int rarity, Levels.LevelTypes levelFlags, AudioClip firstTimeDungeonAudio = null) { customDungeons.Add(new CustomDungeon { dungeonFlow = dungeon, rarity = rarity, LevelTypes = levelFlags, firstTimeDungeonAudio = firstTimeDungeonAudio }); } public static void AddDungeon(DungeonFlow dungeon, int rarity, Levels.LevelTypes levelFlags, string[] levelOverrides = null, AudioClip firstTimeDungeonAudio = null) { customDungeons.Add(new CustomDungeon { dungeonFlow = dungeon, rarity = rarity, LevelTypes = levelFlags, firstTimeDungeonAudio = firstTimeDungeonAudio, levelOverrides = levelOverrides }); } } public class Enemies { public enum SpawnType { Default, Daytime, Outside } public class SpawnableEnemy { public EnemyType enemy; public int rarity; public Levels.LevelTypes spawnLevels; public SpawnType spawnType; public TerminalNode terminalNode; public TerminalKeyword infoKeyword; public string modName; public string[] spawnLevelOverrides; public SpawnableEnemy(EnemyType enemy, int rarity, Levels.LevelTypes spawnLevels, SpawnType spawnType, string[] spawnLevelOverrides = null) { this.enemy = enemy; this.rarity = rarity; this.spawnLevels = spawnLevels; this.spawnType = spawnType; this.spawnLevelOverrides = spawnLevelOverrides; } } [CompilerGenerated] private static class <>O { public static hook_Awake <0>__RegisterLevelEnemies; public static hook_Start <1>__Terminal_Start; } public static List<SpawnableEnemy> spawnableEnemies = new List<SpawnableEnemy>(); public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown object obj = <>O.<0>__RegisterLevelEnemies; if (obj == null) { hook_Awake val = RegisterLevelEnemies; <>O.<0>__RegisterLevelEnemies = val; obj = (object)val; } StartOfRound.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__Terminal_Start; if (obj2 == null) { hook_Start val2 = Terminal_Start; <>O.<1>__Terminal_Start = val2; obj2 = (object)val2; } Terminal.Start += (hook_Start)obj2; } private static void Terminal_Start(orig_Start orig, Terminal self) { //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Expected O, but got Unknown TerminalKeyword val = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info"); List<string> list = new List<string>(); foreach (SpawnableEnemy spawnableEnemy in spawnableEnemies) { if (list.Contains(spawnableEnemy.enemy.enemyName)) { Plugin.logger.LogInfo((object)("Skipping " + spawnableEnemy.enemy.enemyName + " because it was already added")); continue; } if ((Object)(object)spawnableEnemy.terminalNode == (Object)null) { spawnableEnemy.terminalNode = ScriptableObject.CreateInstance<TerminalNode>(); spawnableEnemy.terminalNode.displayText = spawnableEnemy.enemy.enemyName + "\n\nDanger level: Unknown\n\n[No information about this creature was found.]\n\n"; spawnableEnemy.terminalNode.clearPreviousText = true; spawnableEnemy.terminalNode.maxCharactersToType = 35; spawnableEnemy.terminalNode.creatureName = spawnableEnemy.enemy.enemyName; } if (self.enemyFiles.Any((TerminalNode x) => x.creatureName == spawnableEnemy.terminalNode.creatureName)) { Plugin.logger.LogInfo((object)("Skipping " + spawnableEnemy.enemy.enemyName + " because it was already added")); continue; } TerminalKeyword keyword2 = (((Object)(object)spawnableEnemy.infoKeyword != (Object)null) ? spawnableEnemy.infoKeyword : TerminalUtils.CreateTerminalKeyword(spawnableEnemy.terminalNode.creatureName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val)); keyword2.defaultVerb = val; List<TerminalKeyword> list2 = self.terminalNodes.allKeywords.ToList(); if (!list2.Any((TerminalKeyword x) => x.word == keyword2.word)) { list2.Add(keyword2); self.terminalNodes.allKeywords = list2.ToArray(); } List<CompatibleNoun> list3 = val.compatibleNouns.ToList(); if (!list3.Any((CompatibleNoun x) => x.noun.word == keyword2.word)) { list3.Add(new CompatibleNoun { noun = keyword2, result = spawnableEnemy.terminalNode }); } val.compatibleNouns = list3.ToArray(); spawnableEnemy.terminalNode.creatureFileID = self.enemyFiles.Count; self.enemyFiles.Add(spawnableEnemy.terminalNode); spawnableEnemy.enemy.enemyPrefab.GetComponentInChildren<ScanNodeProperties>().creatureScanID = spawnableEnemy.terminalNode.creatureFileID; } orig.Invoke(self); } private static void RegisterLevelEnemies(orig_Awake orig, StartOfRound self) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown orig.Invoke(self); foreach (SpawnableEnemy spawnableEnemy in spawnableEnemies) { SelectableLevel[] levels = self.levels; foreach (SelectableLevel val in levels) { string name = ((Object)val).name; bool flag = spawnableEnemy.spawnLevels.HasFlag(Levels.LevelTypes.All) || (spawnableEnemy.spawnLevelOverrides != null && spawnableEnemy.spawnLevelOverrides.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant())); if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag)) { continue; } Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name))); if (!flag && !spawnableEnemy.spawnLevels.HasFlag(levelTypes)) { continue; } SpawnableEnemyWithRarity item2 = new SpawnableEnemyWithRarity { enemyType = spawnableEnemy.enemy, rarity = spawnableEnemy.rarity }; switch (spawnableEnemy.spawnType) { case SpawnType.Default: if (!val.Enemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy)) { val.Enemies.Add(item2); Plugin.logger.LogInfo((object)("Added " + ((Object)spawnableEnemy.enemy).name + " to " + name + " with SpawnType [Default]")); } break; case SpawnType.Daytime: if (!val.DaytimeEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy)) { val.DaytimeEnemies.Add(item2); Plugin.logger.LogInfo((object)("Added " + ((Object)spawnableEnemy.enemy).name + " to " + name + " with SpawnType [Daytime]")); } break; case SpawnType.Outside: if (!val.OutsideEnemies.Any((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)spawnableEnemy.enemy)) { val.OutsideEnemies.Add(item2); Plugin.logger.LogInfo((object)("Added " + ((Object)spawnableEnemy.enemy).name + " to " + name + " with SpawnType [Outside]")); } break; } } } } public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, SpawnType spawnType, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null) { SpawnableEnemy spawnableEnemy = new SpawnableEnemy(enemy, rarity, levelFlags, spawnType); spawnableEnemy.terminalNode = infoNode; spawnableEnemy.infoKeyword = infoKeyword; Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; spawnableEnemy.modName = name; spawnableEnemies.Add(spawnableEnemy); } public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, SpawnType spawnType, string[] spawnLevelOverrides = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null) { SpawnableEnemy spawnableEnemy = new SpawnableEnemy(enemy, rarity, levelFlags, spawnType, spawnLevelOverrides); spawnableEnemy.terminalNode = infoNode; spawnableEnemy.infoKeyword = infoKeyword; Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; spawnableEnemy.modName = name; spawnableEnemies.Add(spawnableEnemy); } public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null) { SpawnableEnemy spawnableEnemy = new SpawnableEnemy(enemy, rarity, levelFlags, enemy.isDaytimeEnemy ? SpawnType.Daytime : (enemy.isOutsideEnemy ? SpawnType.Outside : SpawnType.Default)); spawnableEnemy.terminalNode = infoNode; spawnableEnemy.infoKeyword = infoKeyword; Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; spawnableEnemy.modName = name; spawnableEnemies.Add(spawnableEnemy); } public static void RegisterEnemy(EnemyType enemy, int rarity, Levels.LevelTypes levelFlags, string[] spawnLevelOverrides = null, TerminalNode infoNode = null, TerminalKeyword infoKeyword = null) { SpawnableEnemy spawnableEnemy = new SpawnableEnemy(enemy, rarity, levelFlags, enemy.isDaytimeEnemy ? SpawnType.Daytime : (enemy.isOutsideEnemy ? SpawnType.Outside : SpawnType.Default), spawnLevelOverrides); spawnableEnemy.terminalNode = infoNode; spawnableEnemy.infoKeyword = infoKeyword; Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; spawnableEnemy.modName = name; spawnableEnemies.Add(spawnableEnemy); } } public class Items { public class ScrapItem { public Item item; public int rarity; public Levels.LevelTypes spawnLevels; public string[] spawnLevelOverrides; public string modName; public ScrapItem(Item item, int rarity, Levels.LevelTypes spawnLevels = Levels.LevelTypes.None, string[] spawnLevelOverrides = null) { this.item = item; this.rarity = rarity; this.spawnLevels = spawnLevels; } } public class PlainItem { public Item item; public string modName; public PlainItem(Item item) { this.item = item; } } public class ShopItem { public Item item; public TerminalNode buyNode1; public TerminalNode buyNode2; public TerminalNode itemInfo; public int price; public string modName; public ShopItem(Item item, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = 0) { this.item = item; this.price = price; if ((Object)(object)buyNode1 != (Object)null) { this.buyNode1 = buyNode1; } if ((Object)(object)buyNode2 != (Object)null) { this.buyNode2 = buyNode2; } if ((Object)(object)itemInfo != (Object)null) { this.itemInfo = itemInfo; } } } [CompilerGenerated] private static class <>O { public static hook_Awake <0>__StartOfRound_Awake; public static hook_Awake <1>__Terminal_Awake; } public static List<ScrapItem> scrapItems = new List<ScrapItem>(); public static List<ShopItem> shopItems = new List<ShopItem>(); public static List<PlainItem> plainItems = new List<PlainItem>(); public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown object obj = <>O.<0>__StartOfRound_Awake; if (obj == null) { hook_Awake val = StartOfRound_Awake; <>O.<0>__StartOfRound_Awake = val; obj = (object)val; } StartOfRound.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__Terminal_Awake; if (obj2 == null) { hook_Awake val2 = Terminal_Awake; <>O.<1>__Terminal_Awake = val2; obj2 = (object)val2; } Terminal.Awake += (hook_Awake)obj2; } private static void Terminal_Awake(orig_Awake orig, Terminal self) { //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected O, but got Unknown //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Expected O, but got Unknown //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Expected O, but got Unknown //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Expected O, but got Unknown List<Item> list = self.buyableItemsList.ToList(); TerminalKeyword val = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy"); TerminalNode result = val.compatibleNouns[0].result.terminalOptions[1].result; TerminalKeyword val2 = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info"); Plugin.logger.LogInfo((object)$"Adding {shopItems.Count} items to terminal"); foreach (ShopItem item in shopItems) { if (list.Any((Item x) => x.itemName == item.item.itemName)) { Plugin.logger.LogInfo((object)("Item " + item.item.itemName + " already exists in terminal, skipping")); continue; } if (item.price == -1) { item.price = item.item.creditsWorth; } else { item.item.creditsWorth = item.price; } list.Add(item.item); string itemName = item.item.itemName; char c = itemName[itemName.Length - 1]; string text = itemName; TerminalNode val3 = item.buyNode2; if ((Object)(object)val3 == (Object)null) { val3 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val3).name = itemName.Replace(" ", "-") + "BuyNode2"; val3.displayText = "Ordered [variableAmount] " + text + ". Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n"; val3.clearPreviousText = true; val3.maxCharactersToType = 15; } val3.buyItemIndex = list.Count - 1; val3.isConfirmationNode = false; val3.itemCost = item.price; val3.playSyncedClip = 0; TerminalNode val4 = item.buyNode1; if ((Object)(object)val4 == (Object)null) { val4 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val4).name = itemName.Replace(" ", "-") + "BuyNode1"; val4.displayText = "You have requested to order " + text + ". Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n"; val4.clearPreviousText = true; val4.maxCharactersToType = 35; } val4.buyItemIndex = list.Count - 1; val4.isConfirmationNode = true; val4.overrideOptions = true; val4.itemCost = item.price; val4.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { new CompatibleNoun { noun = self.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "confirm"), result = val3 }, new CompatibleNoun { noun = self.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "deny"), result = result } }; TerminalKeyword val5 = TerminalUtils.CreateTerminalKeyword(itemName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val); List<TerminalKeyword> list2 = self.terminalNodes.allKeywords.ToList(); list2.Add(val5); self.terminalNodes.allKeywords = list2.ToArray(); List<CompatibleNoun> list3 = val.compatibleNouns.ToList(); list3.Add(new CompatibleNoun { noun = val5, result = val4 }); val.compatibleNouns = list3.ToArray(); TerminalNode val6 = item.itemInfo; if ((Object)(object)val6 == (Object)null) { val6 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val6).name = itemName.Replace(" ", "-") + "InfoNode"; val6.displayText = "[No information about this object was found.]\n\n"; val6.clearPreviousText = true; val6.maxCharactersToType = 25; } self.terminalNodes.allKeywords = list2.ToArray(); List<CompatibleNoun> list4 = val2.compatibleNouns.ToList(); list4.Add(new CompatibleNoun { noun = val5, result = val6 }); val2.compatibleNouns = list4.ToArray(); Plugin.logger.LogInfo((object)(item.modName + " registered item: " + item.item.itemName)); } self.buyableItemsList = list.ToArray(); orig.Invoke(self); } private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown orig.Invoke(self); foreach (ScrapItem scrapItem in scrapItems) { SelectableLevel[] levels = self.levels; foreach (SelectableLevel val in levels) { string name = ((Object)val).name; bool flag = scrapItem.spawnLevels.HasFlag(Levels.LevelTypes.All) || (scrapItem.spawnLevelOverrides != null && scrapItem.spawnLevelOverrides.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant())); if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag)) { continue; } Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name))); if (flag || scrapItem.spawnLevels.HasFlag(levelTypes)) { SpawnableItemWithRarity item2 = new SpawnableItemWithRarity { spawnableItem = scrapItem.item, rarity = scrapItem.rarity }; if (!val.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)scrapItem.item)) { val.spawnableScrap.Add(item2); } } } } foreach (ScrapItem scrapItem2 in scrapItems) { if (!self.allItemsList.itemsList.Contains(scrapItem2.item)) { Plugin.logger.LogInfo((object)(scrapItem2.modName + " registered item: " + scrapItem2.item.itemName)); self.allItemsList.itemsList.Add(scrapItem2.item); } } foreach (ShopItem shopItem in shopItems) { if (!self.allItemsList.itemsList.Contains(shopItem.item)) { Plugin.logger.LogInfo((object)(shopItem.modName + " registered item: " + shopItem.item.itemName)); self.allItemsList.itemsList.Add(shopItem.item); } } foreach (PlainItem plainItem in plainItems) { if (!self.allItemsList.itemsList.Contains(plainItem.item)) { Plugin.logger.LogInfo((object)(plainItem.modName + " registered item: " + plainItem.item.itemName)); self.allItemsList.itemsList.Add(plainItem.item); } } } public static void RegisterScrap(Item spawnableItem, int rarity, Levels.LevelTypes levelFlags) { ScrapItem scrapItem = new ScrapItem(spawnableItem, rarity, levelFlags); Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; scrapItem.modName = name; scrapItems.Add(scrapItem); } public static void RegisterScrap(Item spawnableItem, int rarity, Levels.LevelTypes levelFlags = Levels.LevelTypes.None, string[] levelOverrides = null) { ScrapItem scrapItem = new ScrapItem(spawnableItem, rarity, levelFlags, levelOverrides); Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; scrapItem.modName = name; scrapItems.Add(scrapItem); } public static void RegisterShopItem(Item shopItem, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = -1) { ShopItem shopItem2 = new ShopItem(shopItem, buyNode1, buyNode2, itemInfo, price); Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; shopItem2.modName = name; shopItems.Add(shopItem2); } public static void RegisterShopItem(Item shopItem, int price = -1) { ShopItem shopItem2 = new ShopItem(shopItem, null, null, null, price); Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; shopItem2.modName = name; shopItems.Add(shopItem2); } public static void RegisterItem(Item plainItem) { PlainItem plainItem2 = new PlainItem(plainItem); Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; plainItem2.modName = name; plainItems.Add(plainItem2); } } public class Levels { [Flags] public enum LevelTypes { None = 1, ExperimentationLevel = 4, AssuranceLevel = 8, VowLevel = 0x10, OffenseLevel = 0x20, MarchLevel = 0x40, RendLevel = 0x80, DineLevel = 0x100, TitanLevel = 0x200, Vanilla = 0x3FC, All = -1 } } public class MapObjects { public class RegisteredMapObject { public SpawnableMapObject mapObject; public SpawnableOutsideObjectWithRarity outsideObject; public Levels.LevelTypes levels; public string[] spawnLevelOverrides; public Func<SelectableLevel, AnimationCurve> spawnRateFunction; } [CompilerGenerated] private static class <>O { public static hook_Awake <0>__StartOfRound_Awake; public static hook_SpawnMapObjects <1>__RoundManager_SpawnMapObjects; } public static List<RegisteredMapObject> mapObjects = new List<RegisteredMapObject>(); public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown object obj = <>O.<0>__StartOfRound_Awake; if (obj == null) { hook_Awake val = StartOfRound_Awake; <>O.<0>__StartOfRound_Awake = val; obj = (object)val; } StartOfRound.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__RoundManager_SpawnMapObjects; if (obj2 == null) { hook_SpawnMapObjects val2 = RoundManager_SpawnMapObjects; <>O.<1>__RoundManager_SpawnMapObjects = val2; obj2 = (object)val2; } RoundManager.SpawnMapObjects += (hook_SpawnMapObjects)obj2; } private static void RoundManager_SpawnMapObjects(orig_SpawnMapObjects orig, RoundManager self) { RandomMapObject[] array = Object.FindObjectsOfType<RandomMapObject>(); RandomMapObject[] array2 = array; foreach (RandomMapObject val in array2) { foreach (RegisteredMapObject mapObject in mapObjects) { if (mapObject.mapObject != null && !val.spawnablePrefabs.Any((GameObject prefab) => (Object)(object)prefab == (Object)(object)mapObject.mapObject.prefabToSpawn)) { val.spawnablePrefabs.Add(mapObject.mapObject.prefabToSpawn); } } } orig.Invoke(self); } private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self) { orig.Invoke(self); foreach (RegisteredMapObject mapObject in mapObjects) { SelectableLevel[] levels = self.levels; foreach (SelectableLevel val in levels) { string name = ((Object)val).name; bool flag = mapObject.levels.HasFlag(Levels.LevelTypes.All) || (mapObject.spawnLevelOverrides != null && mapObject.spawnLevelOverrides.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant())); if (!(Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag)) { continue; } Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name))); if (!flag && !mapObject.levels.HasFlag(levelTypes)) { continue; } if (mapObject.mapObject != null) { if (!val.spawnableMapObjects.Any((SpawnableMapObject x) => (Object)(object)x.prefabToSpawn == (Object)(object)mapObject.mapObject.prefabToSpawn)) { List<SpawnableMapObject> list = val.spawnableMapObjects.ToList(); list.RemoveAll((SpawnableMapObject x) => (Object)(object)x.prefabToSpawn == (Object)(object)mapObject.mapObject.prefabToSpawn); val.spawnableMapObjects = list.ToArray(); } SpawnableMapObject mapObject2 = mapObject.mapObject; if (mapObject.spawnRateFunction != null) { mapObject2.numberToSpawn = mapObject.spawnRateFunction(val); } List<SpawnableMapObject> list2 = val.spawnableMapObjects.ToList(); list2.Add(mapObject2); val.spawnableMapObjects = list2.ToArray(); Plugin.logger.LogInfo((object)("Added " + ((Object)mapObject2.prefabToSpawn).name + " to " + name)); } else { if (mapObject.outsideObject == null) { continue; } if (!val.spawnableOutsideObjects.Any((SpawnableOutsideObjectWithRarity x) => (Object)(object)x.spawnableObject.prefabToSpawn == (Object)(object)mapObject.outsideObject.spawnableObject.prefabToSpawn)) { List<SpawnableOutsideObjectWithRarity> list3 = val.spawnableOutsideObjects.ToList(); list3.RemoveAll((SpawnableOutsideObjectWithRarity x) => (Object)(object)x.spawnableObject.prefabToSpawn == (Object)(object)mapObject.outsideObject.spawnableObject.prefabToSpawn); val.spawnableOutsideObjects = list3.ToArray(); } SpawnableOutsideObjectWithRarity outsideObject = mapObject.outsideObject; if (mapObject.spawnRateFunction != null) { outsideObject.randomAmount = mapObject.spawnRateFunction(val); } List<SpawnableOutsideObjectWithRarity> list4 = val.spawnableOutsideObjects.ToList(); list4.Add(outsideObject); val.spawnableOutsideObjects = list4.ToArray(); Plugin.logger.LogInfo((object)("Added " + ((Object)outsideObject.spawnableObject.prefabToSpawn).name + " to " + name)); } } } } public static void RegisterMapObject(SpawnableMapObjectDef mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null) { RegisterMapObject(mapObject.spawnableMapObject, levels, spawnRateFunction); } public static void RegisterMapObject(SpawnableMapObjectDef mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null) { RegisterMapObject(mapObject.spawnableMapObject, levels, levelOverrides, spawnRateFunction); } public static void RegisterMapObject(SpawnableMapObject mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null) { mapObjects.Add(new RegisteredMapObject { mapObject = mapObject, levels = levels, spawnRateFunction = spawnRateFunction }); } public static void RegisterMapObject(SpawnableMapObject mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null) { mapObjects.Add(new RegisteredMapObject { mapObject = mapObject, levels = levels, spawnRateFunction = spawnRateFunction, spawnLevelOverrides = levelOverrides }); } public static void RegisterOutsideObject(SpawnableOutsideObjectDef mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null) { RegisterOutsideObject(mapObject.spawnableMapObject, levels, spawnRateFunction); } public static void RegisterOutsideObject(SpawnableOutsideObjectDef mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null) { RegisterOutsideObject(mapObject.spawnableMapObject, levels, levelOverrides, spawnRateFunction); } public static void RegisterOutsideObject(SpawnableOutsideObjectWithRarity mapObject, Levels.LevelTypes levels, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null) { mapObjects.Add(new RegisteredMapObject { outsideObject = mapObject, levels = levels, spawnRateFunction = spawnRateFunction }); } public static void RegisterOutsideObject(SpawnableOutsideObjectWithRarity mapObject, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] levelOverrides = null, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null) { mapObjects.Add(new RegisteredMapObject { outsideObject = mapObject, levels = levels, spawnRateFunction = spawnRateFunction, spawnLevelOverrides = levelOverrides }); } } public class NetworkPrefabs { [CompilerGenerated] private static class <>O { public static hook_Start <0>__GameNetworkManager_Start; } private static List<GameObject> _networkPrefabs = new List<GameObject>(); internal static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown object obj = <>O.<0>__GameNetworkManager_Start; if (obj == null) { hook_Start val = GameNetworkManager_Start; <>O.<0>__GameNetworkManager_Start = val; obj = (object)val; } GameNetworkManager.Start += (hook_Start)obj; } public static void RegisterNetworkPrefab(GameObject prefab) { _networkPrefabs.Add(prefab); } private static void GameNetworkManager_Start(orig_Start orig, GameNetworkManager self) { orig.Invoke(self); foreach (GameObject networkPrefab in _networkPrefabs) { ((Component)self).GetComponent<NetworkManager>().AddNetworkPrefab(networkPrefab); } } } public class Shaders { public static void FixShaders(GameObject gameObject) { Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { Material[] materials = val.materials; foreach (Material val2 in materials) { if (((Object)val2.shader).name.Contains("Standard")) { val2.shader = Shader.Find("HDRP/Lit"); } } } } } public class TerminalUtils { public static TerminalKeyword CreateTerminalKeyword(string word, bool isVerb = false, CompatibleNoun[] compatibleNouns = null, TerminalNode specialKeywordResult = null, TerminalKeyword defaultVerb = null, bool accessTerminalObjects = false) { TerminalKeyword val = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val).name = word; val.word = word; val.isVerb = isVerb; val.compatibleNouns = compatibleNouns; val.specialKeywordResult = specialKeywordResult; val.defaultVerb = defaultVerb; val.accessTerminalObjects = accessTerminalObjects; return val; } } public enum StoreType { None, ShipUpgrade, Decor } public class Unlockables { public class RegisteredUnlockable { public UnlockableItem unlockable; public StoreType StoreType; public TerminalNode buyNode1; public TerminalNode buyNode2; public TerminalNode itemInfo; public int price; public string modName; public RegisteredUnlockable(UnlockableItem unlockable, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = -1) { this.unlockable = unlockable; this.buyNode1 = buyNode1; this.buyNode2 = buyNode2; this.itemInfo = itemInfo; this.price = price; } } [CompilerGenerated] private static class <>O { public static hook_Awake <0>__StartOfRound_Awake; public static hook_Start <1>__Terminal_Start; public static hook_TextPostProcess <2>__Terminal_TextPostProcess; } public static List<RegisteredUnlockable> registeredUnlockables = new List<RegisteredUnlockable>(); public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown object obj = <>O.<0>__StartOfRound_Awake; if (obj == null) { hook_Awake val = StartOfRound_Awake; <>O.<0>__StartOfRound_Awake = val; obj = (object)val; } StartOfRound.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__Terminal_Start; if (obj2 == null) { hook_Start val2 = Terminal_Start; <>O.<1>__Terminal_Start = val2; obj2 = (object)val2; } Terminal.Start += (hook_Start)obj2; object obj3 = <>O.<2>__Terminal_TextPostProcess; if (obj3 == null) { hook_TextPostProcess val3 = Terminal_TextPostProcess; <>O.<2>__Terminal_TextPostProcess = val3; obj3 = (object)val3; } Terminal.TextPostProcess += (hook_TextPostProcess)obj3; } private static string Terminal_TextPostProcess(orig_TextPostProcess orig, Terminal self, string modifiedDisplayText, TerminalNode node) { if (modifiedDisplayText.Contains("[buyableItemsList]") && modifiedDisplayText.Contains("[unlockablesSelectionList]")) { int num = modifiedDisplayText.IndexOf(":"); foreach (RegisteredUnlockable registeredUnlockable in registeredUnlockables) { if (registeredUnlockable.StoreType == StoreType.ShipUpgrade) { string unlockableName = registeredUnlockable.unlockable.unlockableName; int price = registeredUnlockable.price; string value = $"\n* {unlockableName} // Price: ${price}"; modifiedDisplayText = modifiedDisplayText.Insert(num + 1, value); } } } return orig.Invoke(self, modifiedDisplayText, node); } private static void Terminal_Start(orig_Start orig, Terminal self) { //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Expected O, but got Unknown //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Expected O, but got Unknown //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Expected O, but got Unknown TerminalKeyword val = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy"); TerminalNode result = val.compatibleNouns[0].result.terminalOptions[1].result; TerminalKeyword val2 = self.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "info"); List<RegisteredUnlockable> list = registeredUnlockables.FindAll((RegisteredUnlockable unlockable) => unlockable.price != -1).ToList(); Plugin.logger.LogInfo((object)$"Adding {list.Count} items to terminal"); foreach (RegisteredUnlockable item in list) { string unlockableName = item.unlockable.unlockableName; TerminalKeyword keyword3 = TerminalUtils.CreateTerminalKeyword(unlockableName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, val); if (self.terminalNodes.allKeywords.Any((TerminalKeyword kw) => kw.word == keyword3.word)) { Plugin.logger.LogInfo((object)("Keyword " + keyword3.word + " already registed, skipping.")); continue; } int shipUnlockableID = StartOfRound.Instance.unlockablesList.unlockables.FindIndex((UnlockableItem unlockable) => unlockable.unlockableName == item.unlockable.unlockableName); StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { Debug.Log((object)"STARTOFROUND INSTANCE NOT FOUND"); } if (item.price == -1 && (Object)(object)item.buyNode1 != (Object)null) { item.price = item.buyNode1.itemCost; } char c = unlockableName[unlockableName.Length - 1]; string text = unlockableName; TerminalNode val3 = item.buyNode2; if ((Object)(object)val3 == (Object)null) { val3 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val3).name = unlockableName.Replace(" ", "-") + "BuyNode2"; val3.displayText = "Ordered [variableAmount] " + text + ". Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n"; val3.clearPreviousText = true; val3.maxCharactersToType = 15; } val3.buyItemIndex = -1; val3.shipUnlockableID = shipUnlockableID; val3.buyUnlockable = true; val3.creatureName = unlockableName; val3.isConfirmationNode = false; val3.itemCost = item.price; val3.playSyncedClip = 0; TerminalNode val4 = item.buyNode1; if ((Object)(object)val4 == (Object)null) { val4 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val4).name = unlockableName.Replace(" ", "-") + "BuyNode1"; val4.displayText = "You have requested to order " + text + ". Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n"; val4.clearPreviousText = true; val4.maxCharactersToType = 35; } val4.buyItemIndex = -1; val4.shipUnlockableID = shipUnlockableID; val4.creatureName = unlockableName; val4.isConfirmationNode = true; val4.overrideOptions = true; val4.itemCost = item.price; val4.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { new CompatibleNoun { noun = self.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "confirm"), result = val3 }, new CompatibleNoun { noun = self.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "deny"), result = result } }; if (item.StoreType == StoreType.Decor) { item.unlockable.shopSelectionNode = val4; } else { item.unlockable.shopSelectionNode = null; } List<TerminalKeyword> list2 = self.terminalNodes.allKeywords.ToList(); list2.Add(keyword3); self.terminalNodes.allKeywords = list2.ToArray(); List<CompatibleNoun> list3 = val.compatibleNouns.ToList(); list3.Add(new CompatibleNoun { noun = keyword3, result = val4 }); val.compatibleNouns = list3.ToArray(); TerminalNode val5 = item.itemInfo; if ((Object)(object)val5 == (Object)null) { val5 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val5).name = unlockableName.Replace(" ", "-") + "InfoNode"; val5.displayText = "[No information about this object was found.]\n\n"; val5.clearPreviousText = true; val5.maxCharactersToType = 25; } self.terminalNodes.allKeywords = list2.ToArray(); List<CompatibleNoun> list4 = val2.compatibleNouns.ToList(); list4.Add(new CompatibleNoun { noun = keyword3, result = val5 }); val2.compatibleNouns = list4.ToArray(); Plugin.logger.LogInfo((object)(item.modName + " registered item: " + item.unlockable.unlockableName)); } orig.Invoke(self); } private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self) { orig.Invoke(self); Plugin.logger.LogInfo((object)$"Adding {registeredUnlockables.Count} unlockables to unlockables list"); foreach (RegisteredUnlockable unlockable in registeredUnlockables) { if (self.unlockablesList.unlockables.Any((UnlockableItem x) => x.unlockableName == unlockable.unlockable.unlockableName)) { Plugin.logger.LogInfo((object)("Unlockable " + unlockable.unlockable.unlockableName + " already exists in unlockables list, skipping")); continue; } if ((Object)(object)unlockable.unlockable.prefabObject != (Object)null) { PlaceableShipObject componentInChildren = unlockable.unlockable.prefabObject.GetComponentInChildren<PlaceableShipObject>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.unlockableID = self.unlockablesList.unlockables.Count; } } self.unlockablesList.unlockables.Add(unlockable.unlockable); } } public static void RegisterUnlockable(UnlockableItemDef unlockable, int price = -1, StoreType storeType = StoreType.None) { RegisterUnlockable(unlockable.unlockable, storeType, null, null, null, price); } public static void RegisterUnlockable(UnlockableItem unlockable, int price = -1, StoreType storeType = StoreType.None) { RegisterUnlockable(unlockable, storeType, null, null, null, price); } public static void RegisterUnlockable(UnlockableItemDef unlockable, StoreType storeType = StoreType.None, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = -1) { RegisterUnlockable(unlockable.unlockable, storeType, buyNode1, buyNode2, itemInfo, price); } public static void RegisterUnlockable(UnlockableItem unlockable, StoreType storeType = StoreType.None, TerminalNode buyNode1 = null, TerminalNode buyNode2 = null, TerminalNode itemInfo = null, int price = -1) { RegisteredUnlockable registeredUnlockable = new RegisteredUnlockable(unlockable, buyNode1, buyNode2, itemInfo, price); Assembly callingAssembly = Assembly.GetCallingAssembly(); string name = callingAssembly.GetName().Name; registeredUnlockable.modName = name; registeredUnlockable.StoreType = storeType; registeredUnlockables.Add(registeredUnlockable); } } public class Weathers { public class CustomWeather { public string name; public int weatherVariable1; public int weatherVariable2; public WeatherEffect weatherEffect; public Levels.LevelTypes levels; public string[] spawnLevelOverrides; public CustomWeather(string name, WeatherEffect weatherEffect, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] spawnLevelOverrides = null, int weatherVariable1 = 0, int weatherVariable2 = 0) { this.name = name; this.weatherVariable1 = weatherVariable1; this.weatherVariable2 = weatherVariable2; this.weatherEffect = weatherEffect; this.levels = levels; this.spawnLevelOverrides = spawnLevelOverrides; } } [CompilerGenerated] private static class <>O { public static hook_Awake <0>__TimeOfDay_Awake; public static hook_Awake <1>__StartOfRound_Awake; } public static Dictionary<int, CustomWeather> customWeathers = new Dictionary<int, CustomWeather>(); public static int numCustomWeathers = 0; public static void Init() { //IL_002f: 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) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown new Hook((MethodBase)typeof(Enum).GetMethod("ToString", new Type[0]), typeof(Weathers).GetMethod("ToStringHook")); object obj = <>O.<0>__TimeOfDay_Awake; if (obj == null) { hook_Awake val = TimeOfDay_Awake; <>O.<0>__TimeOfDay_Awake = val; obj = (object)val; } TimeOfDay.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__StartOfRound_Awake; if (obj2 == null) { hook_Awake val2 = StartOfRound_Awake; <>O.<1>__StartOfRound_Awake = val2; obj2 = (object)val2; } StartOfRound.Awake += (hook_Awake)obj2; } private static void StartOfRound_Awake(orig_Awake orig, StartOfRound self) { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown foreach (KeyValuePair<int, CustomWeather> customWeather in customWeathers) { SelectableLevel[] levels = self.levels; foreach (SelectableLevel val in levels) { string name = ((Object)val).name; bool flag = customWeather.Value.levels.HasFlag(Levels.LevelTypes.All) || (customWeather.Value.spawnLevelOverrides != null && customWeather.Value.spawnLevelOverrides.Any((string item) => item.ToLowerInvariant() == name.ToLowerInvariant())); if (Enum.IsDefined(typeof(Levels.LevelTypes), name) || flag) { Levels.LevelTypes levelTypes = (flag ? Levels.LevelTypes.All : ((Levels.LevelTypes)Enum.Parse(typeof(Levels.LevelTypes), name))); List<RandomWeatherWithVariables> list = val.randomWeathers.ToList(); if (flag || customWeather.Value.levels.HasFlag(levelTypes)) { list.Add(new RandomWeatherWithVariables { weatherType = (LevelWeatherType)customWeather.Key, weatherVariable = customWeather.Value.weatherVariable1, weatherVariable2 = customWeather.Value.weatherVariable2 }); Plugin.logger.LogInfo((object)$"Added weather {customWeather.Value.name} to level {((Object)val).name} at weather index: {customWeather.Key}"); } val.randomWeathers = list.ToArray(); } } } orig.Invoke(self); } private static void TimeOfDay_Awake(orig_Awake orig, TimeOfDay self) { List<WeatherEffect> list = self.effects.ToList(); int num = 0; foreach (KeyValuePair<int, CustomWeather> customWeather in customWeathers) { if (customWeather.Key > num) { num = customWeather.Key; } } while (list.Count <= num) { list.Add(null); } foreach (KeyValuePair<int, CustomWeather> customWeather2 in customWeathers) { list[customWeather2.Key] = customWeather2.Value.weatherEffect; } self.effects = list.ToArray(); orig.Invoke(self); } public static string ToStringHook(Func<Enum, string> orig, Enum self) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected I4, but got Unknown if (self.GetType() == typeof(LevelWeatherType) && customWeathers.ContainsKey((int)(LevelWeatherType)(object)self)) { return customWeathers[(int)(LevelWeatherType)(object)self].name; } return orig(self); } public static void RegisterWeather(WeatherDef weather) { RegisterWeather(weather.weatherName, weather.weatherEffect, weather.levels, weather.levelOverrides, weather.weatherVariable1, weather.weatherVariable2); } public static void RegisterWeather(string name, WeatherEffect weatherEffect, Levels.LevelTypes levels = Levels.LevelTypes.None, int weatherVariable1 = 0, int weatherVariable2 = 0) { Array values = Enum.GetValues(typeof(LevelWeatherType)); int num = values.Length - 1; num += numCustomWeathers; numCustomWeathers++; Plugin.logger.LogInfo((object)$"Registering weather {name} at index {num - 1}"); customWeathers.Add(num, new CustomWeather(name, weatherEffect, levels, null, weatherVariable1, weatherVariable2)); } public static void RegisterWeather(string name, WeatherEffect weatherEffect, Levels.LevelTypes levels = Levels.LevelTypes.None, string[] spawnLevelOverrides = null, int weatherVariable1 = 0, int weatherVariable2 = 0) { Array values = Enum.GetValues(typeof(LevelWeatherType)); int num = values.Length - 1; num += numCustomWeathers; numCustomWeathers++; Plugin.logger.LogInfo((object)$"Registering weather {name} at index {num - 1}"); customWeathers.Add(num, new CustomWeather(name, weatherEffect, levels, spawnLevelOverrides, weatherVariable1, weatherVariable2)); } } } namespace LethalLib.Extras { [CreateAssetMenu(menuName = "ScriptableObjects/DungeonDef")] public class DungeonDef : ScriptableObject { public DungeonFlow dungeonFlow; [Range(0f, 300f)] public int rarity; public AudioClip firstTimeDungeonAudio; } [CreateAssetMenu(menuName = "ScriptableObjects/DungeonGraphLine")] public class DungeonGraphLineDef : ScriptableObject { public GraphLine graphLine; } [CreateAssetMenu(menuName = "ScriptableObjects/GameObjectChance")] public class GameObjectChanceDef : ScriptableObject { public GameObjectChance gameObjectChance; } [CreateAssetMenu(menuName = "ScriptableObjects/SpawnableMapObject")] public class SpawnableMapObjectDef : ScriptableObject { public SpawnableMapObject spawnableMapObject; } [CreateAssetMenu(menuName = "ScriptableObjects/SpawnableOutsideObject")] public class SpawnableOutsideObjectDef : ScriptableObject { public SpawnableOutsideObjectWithRarity spawnableMapObject; } [CreateAssetMenu(menuName = "ScriptableObjects/UnlockableItem")] public class UnlockableItemDef : ScriptableObject { public StoreType storeType = StoreType.None; public UnlockableItem unlockable; } [CreateAssetMenu(menuName = "ScriptableObjects/WeatherDef")] public class WeatherDef : ScriptableObject { public string weatherName; public Levels.LevelTypes levels = Levels.LevelTypes.None; public string[] levelOverrides; public int weatherVariable1; public int weatherVariable2; public WeatherEffect weatherEffect; } }
plugins/LethalPaintings.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")] [assembly: AssemblyCompany("LethalPaintings")] [assembly: AssemblyConfiguration("release")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalPaintings")] [assembly: AssemblyTitle("LethalPaintings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 LethalPaintings { internal class Patches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")] [HarmonyPostfix] private static void SetScrapValuePatch(GrabbableObject __instance) { if (__instance.itemProperties.itemName == "Painting") { UpdateTexture(Plugin.PaintingFiles, __instance.itemProperties.materialVariants[0]); UpdateTexture(Plugin.PaintingFiles, __instance.itemProperties.materialVariants[1]); } } private static void UpdateTexture(IReadOnlyList<string> files, Material material) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (files.Count != 0) { int index = Plugin.Rand.Next(files.Count); Texture2D val = new Texture2D(2, 2); Logger.LogInfo((object)("Patching " + ((Object)material).name + " with " + files[index])); ImageConversion.LoadImage(val, File.ReadAllBytes(files[index])); material.mainTexture = (Texture)(object)val; } } } [BepInPlugin("LethalPaintings", "LethalPaintings", "1.0.0")] public class Plugin : BaseUnityPlugin { private static List<string> PosterFolders = new List<string>(); public static readonly List<string> PaintingFiles = new List<string>(); public static Random Rand = new Random(); private void Awake() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) PosterFolders = Directory.GetDirectories(Paths.PluginPath, "LethalPaintings", SearchOption.AllDirectories).ToList(); foreach (string posterFolder in PosterFolders) { string[] files = Directory.GetFiles(Path.Combine(posterFolder, "paintings")); foreach (string text in files) { if (Path.GetExtension(text) != ".old") { PaintingFiles.Add(text); } } } Patches.Init(((BaseUnityPlugin)this).Logger); new Harmony("LethalPaintings").PatchAll(typeof(Patches)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalPaintings is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "LethalPaintings"; public const string PLUGIN_NAME = "LethalPaintings"; public const string PLUGIN_VERSION = "1.0.0"; } }
plugins/mask-the-dead/MaskTheDead.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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 GameNetcodeStuff; using HarmonyLib; using MaskTheDead.Components; using Microsoft.CodeAnalysis; using Unity.Netcode; 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("MaskTheDead")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("If a dead body is next to a mask there's a chance that the body is possesed")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3")] [assembly: AssemblyProduct("MaskTheDead")] [assembly: AssemblyTitle("MaskTheDead")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.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 MaskTheDead { public class Configuration { private ConfigEntry<float> configPossessionChance; private ConfigEntry<int> configRetryPossesionTime; private ConfigEntry<int> configMaskPossessionRange; private ConfigFile File; public float PossesionChance => configPossessionChance.Value; public int RetryPossesionTime => configRetryPossesionTime.Value; public int MaskPossessionRange => configMaskPossessionRange.Value; public int RetryPossesionMinTime => 10000; public Configuration(ConfigFile config) { File = config; configPossessionChance = File.Bind<float>("General", "PossessionChance", 1f, "A number between 0 and 1 (included) representing the percentage of a body being possessed by a nearby mask"); configRetryPossesionTime = File.Bind<int>("General", "RetryPossesionTime", RetryPossesionMinTime, $"Time in milliseconds after which a mask will attempt to posses a nearby body again, less than {RetryPossesionMinTime} milliseconds is ignored"); configMaskPossessionRange = File.Bind<int>("General", "MaskPossessionRange", 10, "Range, in units, of the mask repossession trigger. Only bodies close enough will be considered for repossessions!"); } } [BepInPlugin("MaskTheDead", "MaskTheDead", "1.0.3")] public class Plugin : BaseUnityPlugin { public static ManualLogSource TheLogger; public static Configuration TheConfiguration; public Plugin() { TheConfiguration = new Configuration(((BaseUnityPlugin)this).Config); } private void Awake() { TheLogger = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MaskTheDead is loaded!"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } } public static class PluginInfo { public const string PLUGIN_GUID = "MaskTheDead"; public const string PLUGIN_NAME = "MaskTheDead"; public const string PLUGIN_VERSION = "1.0.3"; } } namespace MaskTheDead.Patchers { [HarmonyPatch] public class GrabbableObjectMaskPatcher { [HarmonyPrefix] [HarmonyPatch(typeof(GrabbableObject), "Start")] private static bool StartPatch(ref GrabbableObject __instance) { if ((Object)(object)__instance == (Object)null) { Plugin.TheLogger.LogFatal((object)"This instance is null, cannot patch item"); return true; } GrabbableObject obj = __instance; HauntedMaskItem val = (HauntedMaskItem)(object)((obj is HauntedMaskItem) ? obj : null); if ((Object)(object)val == (Object)null) { return true; } if (!GameNetworkManager.Instance.isHostingGame) { Plugin.TheLogger.LogInfo((object)"Avoding patch for non hosts"); return true; } Plugin.TheLogger.LogInfo((object)"Adding mask watcher to haunted mask!"); ((Component)val).gameObject.AddComponent<MaskTheDeadComponent>(); return true; } } } namespace MaskTheDead.Components { public class MaskTheDeadComponent : NetworkBehaviour { private readonly Dictionary<GameObject, Coroutine> _NearbyBodies = new Dictionary<GameObject, Coroutine>(); private HauntedMaskItem _MaskComponent; private SphereCollider _Collider; public bool PossessionChancePassed => Random.value < Plugin.TheConfiguration.PossesionChance; public bool CanRetryPossession => Plugin.TheConfiguration.RetryPossesionTime >= Plugin.TheConfiguration.RetryPossesionMinTime; private bool CanComponentUseRagdoll(RagdollGrabbableObject ragdoll) { if (((GrabbableObject)ragdoll).isHeld || ((GrabbableObject)ragdoll).isHeldByEnemy) { Plugin.TheLogger.LogInfo((object)"Cant attempt possession of held ragdoll..."); return false; } if (((GrabbableObject)ragdoll).isInShipRoom) { Plugin.TheLogger.LogInfo((object)"Cant attempt possession of body in ship"); return false; } return true; } private void Awake() { _MaskComponent = ((Component)this).gameObject.GetComponent<HauntedMaskItem>(); _Collider = ((Component)this).gameObject.AddComponent<SphereCollider>(); _Collider.radius = Plugin.TheConfiguration.MaskPossessionRange; ((Collider)_Collider).isTrigger = true; } private void Update() { if (ShouldDispose()) { Dispose(); } else if (((GrabbableObject)_MaskComponent).isHeldByEnemy || ((GrabbableObject)_MaskComponent).isHeld) { ((Collider)_Collider).enabled = false; CleanupCoroutines(); } else { ((Collider)_Collider).enabled = true; } } public override void OnDestroy() { Plugin.TheLogger.LogInfo((object)"Destroying repossession component!"); CleanupCoroutines(); ((NetworkBehaviour)this).OnDestroy(); } public override void OnNetworkDespawn() { Plugin.TheLogger.LogInfo((object)"Network despawn, cleaning repossession component!"); ((NetworkBehaviour)this).OnNetworkDespawn(); CleanupCoroutines(); } private void OnTriggerEnter(Collider other) { if (ShouldDispose()) { Dispose(); return; } RagdollGrabbableObject colliderRagdoll = GetColliderRagdoll(other); if ((Object)(object)colliderRagdoll == (Object)null) { Plugin.TheLogger.LogInfo((object)"Object in mask range is not ragdoll"); } else if (CanComponentUseRagdoll(colliderRagdoll) && !_NearbyBodies.ContainsKey(((Component)colliderRagdoll).gameObject)) { _NearbyBodies.Add(((Component)colliderRagdoll).gameObject, null); AttemptPossesion(colliderRagdoll); } } private void OnTriggerExit(Collider other) { Plugin.TheLogger.LogInfo((object)$"Something is leaving the mask range, i have {_NearbyBodies.Count} body nearby!"); RagdollGrabbableObject colliderRagdoll = GetColliderRagdoll(other); Coroutine value; if ((Object)(object)colliderRagdoll == (Object)null) { Plugin.TheLogger.LogInfo((object)"The collider leaving is not of a ragdoll"); } else if (_NearbyBodies.TryGetValue(((Component)colliderRagdoll).gameObject, out value)) { if (value != null) { Plugin.TheLogger.LogInfo((object)"Stopping coroutine for body leaving mask range"); ((MonoBehaviour)this).StopCoroutine(value); } _NearbyBodies.Remove(((Component)colliderRagdoll).gameObject); } else { Plugin.TheLogger.LogWarning((object)"Body leaving mask range was not in dicitonary of bodies!"); } } private RagdollGrabbableObject GetColliderRagdoll(Collider other) { RagdollGrabbableObject component = ((Component)other).gameObject.GetComponent<RagdollGrabbableObject>(); Plugin.TheLogger.LogInfo((object)$"Collided with {((Component)other).gameObject}"); if ((Object)(object)component != (Object)null && component.bodyID.Value >= 0) { Plugin.TheLogger.LogInfo((object)"Found ragdoll, lucky!"); return component; } if (!((Object)other).name.Contains(".L") && !((Object)other).name.Contains(".R")) { Plugin.TheLogger.LogInfo((object)"This is not a bone!"); return null; } Plugin.TheLogger.LogInfo((object)"Collided with a bone of a character, finding ragdoll on parents"); return ((Component)other).gameObject.GetComponentInParent<RagdollGrabbableObject>(); } private IEnumerator RepossessionCoroutine(object o) { yield return (object)new WaitForSeconds((float)(Plugin.TheConfiguration.RetryPossesionTime / 1000)); yield return (object)new WaitForEndOfFrame(); RagdollGrabbableObject val = (RagdollGrabbableObject)((o is RagdollGrabbableObject) ? o : null); if ((Object)(object)val != (Object)null && _NearbyBodies.TryGetValue(((Component)val).gameObject, out var _)) { Plugin.TheLogger.LogInfo((object)"Ragdoll timer elapsed, attempting possession!"); _NearbyBodies[((Component)val).gameObject] = null; AttemptPossesion(val); } else { Plugin.TheLogger.LogWarning((object)"Ragdoll was deleted, stopping repossession retry!"); } } private void CleanupCoroutines() { if (_NearbyBodies.Count == 0) { return; } Plugin.TheLogger.LogInfo((object)"Cleaning up all nearby bodies!"); foreach (KeyValuePair<GameObject, Coroutine> nearbyBody in _NearbyBodies) { if (nearbyBody.Value != null) { ((MonoBehaviour)this).StopCoroutine(nearbyBody.Value); } } _NearbyBodies.Clear(); } private void AttemptPossesion(RagdollGrabbableObject ragdoll) { if (!PossessionChancePassed) { Plugin.TheLogger.LogInfo((object)"Chance failed, will not possess body"); if (CanRetryPossession) { Plugin.TheLogger.LogInfo((object)"Starting coroutine for repossession"); if (_NearbyBodies[((Component)ragdoll).gameObject] != null) { ((MonoBehaviour)this).StopCoroutine(_NearbyBodies[((Component)ragdoll).gameObject]); } Coroutine value = ((MonoBehaviour)this).StartCoroutine("RepossessionCoroutine", (object)ragdoll); _NearbyBodies[((Component)ragdoll).gameObject] = value; } } else { Plugin.TheLogger.LogInfo((object)"Chance for possession OK"); BeginPossession(ragdoll); } } private void BeginPossession(RagdollGrabbableObject ragdoll) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) Plugin.TheLogger.LogInfo((object)"!!POSSESSING DEAD BODY!!"); HauntedMaskItem component = ((Component)this).gameObject.GetComponent<HauntedMaskItem>(); if ((Object)(object)component == (Object)null) { Plugin.TheLogger.LogFatal((object)"Could not find mask item component, aborting possession!"); return; } Plugin.TheLogger.LogInfo((object)"Spawning mimic"); if ((Object)(object)ragdoll.ragdoll.playerScript == (Object)null) { Plugin.TheLogger.LogFatal((object)"Ragdoll's player script is null, aborting mimic spawn!"); return; } ((NetworkBehaviour)component).NetworkObject.RemoveOwnership(); ((NetworkBehaviour)ragdoll).NetworkObject.RemoveOwnership(); SetPreviouslyHeldByOf(component, ragdoll.ragdoll.playerScript); component.CreateMimicServerRpc(((GrabbableObject)ragdoll).isInFactory, ((Component)ragdoll.ragdoll).transform.position); if ((Object)(object)component != (Object)null) { ((NetworkBehaviour)component).NetworkObject.Despawn(true); Object.Destroy((Object)(object)component); if ((Object)(object)((GrabbableObject)component).radarIcon != (Object)null && (Object)(object)((Component)((GrabbableObject)component).radarIcon).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)((GrabbableObject)component).radarIcon).gameObject); } } if ((Object)(object)ragdoll != (Object)null) { ((NetworkBehaviour)ragdoll).NetworkObject.Despawn(true); Object.Destroy((Object)(object)ragdoll); } } private void SetPreviouslyHeldByOf(HauntedMaskItem item, PlayerControllerB c) { ((object)item).GetType().GetField("previousPlayerHeldBy", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(item, c); Plugin.TheLogger.LogInfo((object)"Set private field previousPlayerHeldBy"); } private bool HasFinishedAttaching(HauntedMaskItem item) { return (bool)((object)item).GetType().GetField("finishedAttaching", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(item); } private bool ShouldDispose() { if (HasFinishedAttaching(_MaskComponent)) { Plugin.TheLogger.LogInfo((object)">> MASK HAS ATTACHED ITSELF TO SOMEONE <<"); Plugin.TheLogger.LogInfo((object)">> KILLING MASKTHEDEAD COMPONENT <<"); return true; } if ((Object)(object)_MaskComponent == (Object)null || (Object)(object)_Collider == (Object)null) { Plugin.TheLogger.LogWarning((object)">> MASK OR COLLIDER IS NULL <<"); Plugin.TheLogger.LogInfo((object)">> KILLING MASKTHEDEAD COMPONENT <<"); return true; } return false; } private void Dispose() { Plugin.TheLogger.LogInfo((object)">> DISPOSING <<"); Object.Destroy((Object)(object)this); } } }
plugins/MaskedEnemyRework.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; 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 GameNetcodeStuff; using HarmonyLib; using MaskedEnemyRework.Patches; using Microsoft.CodeAnalysis; 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.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("MaskedEnemyRework")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("2.1.0.0")] [assembly: AssemblyInformationalVersion("2.1.0")] [assembly: AssemblyProduct("MaskedEnemyRework")] [assembly: AssemblyTitle("MaskedEnemyRework")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.0.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 MaskedEnemyRework { [BepInPlugin("MaskedEnemyRework", "MaskedEnemyRework", "2.1.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("MaskedEnemyRework"); private static Plugin Instance; internal ManualLogSource logger; private ConfigEntry<bool> RemoveMasksConfig; private ConfigEntry<bool> RemoveZombieArmsConfig; private ConfigEntry<bool> UseSpawnRarityConfig; private ConfigEntry<int> SpawnRarityConfig; private ConfigEntry<bool> CanSpawnOutsideConfig; private ConfigEntry<int> MaxSpawnCountConfig; private ConfigEntry<bool> ZombieApocalypeModeConfig; private ConfigEntry<bool> UseVanillaSpawnsConfig; private ConfigEntry<int> ZombieApocalypeRandomChanceConfig; private ConfigEntry<float> InsideEnemySpawnCurveConfig; private ConfigEntry<float> MiddayInsideEnemySpawnCurveConfig; private ConfigEntry<float> StartOutsideEnemySpawnCurveConfig; private ConfigEntry<float> MidOutsideEnemySpawnCurveConfig; private ConfigEntry<float> EndOutsideEnemySpawnCurveConfig; public static bool RemoveMasks; public static bool RemoveZombieArms; public static bool UseSpawnRarity; public static int SpawnRarity; public static bool CanSpawnOutside; public static int MaxSpawnCount; public static bool ZombieApocalypseMode; public static bool UseVanillaSpawns; public static int RandomChanceZombieApocalypse; public static float InsideEnemySpawnCurve; public static float MiddayInsideEnemySpawnCurve; public static float StartOutsideEnemySpawnCurve; public static float MidOutsideEnemySpawnCurve; public static float EndOutsideEnemySpawnCurve; public static int PlayerCount; public static SpawnableEnemyWithRarity maskedPrefab; public static SpawnableEnemyWithRarity flowerPrefab; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } RemoveMasksConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Remove Mask From Masked Enemy", true, "Whether or not the Masked Enemy has a mask on."); RemoveZombieArmsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Remove Zombie Arms", true, "Remove the animation where the Masked raise arms like a zombie."); UseVanillaSpawnsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Vanilla Spawns", false, "Ignores anything else in this mod. Only uses the above settings from this config. Will not spawn on all moons. will ignore EVERYTHING in the config below this point."); UseSpawnRarityConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawns", "Use Spawn Rarity", false, "Use custom spawn rate from config. If this is false, the masked spawns at the same rate as the Bracken. If true, will spawn at whatever rarity is given in Spawn Rarity config option"); SpawnRarityConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Spawns", "Spawn Rarity", 15, "The rarity for the Masked Enemy to spawn. The higher the number, the more likely to spawn. Can go to 1000000000, any higher will break. Use Spawn Rarity must be set to True"); CanSpawnOutsideConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawns", "Allow Masked To Spawn Outside", false, "Whether the Masked Enemy can spawn outside the building"); MaxSpawnCountConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Spawns", "Max Number of Masked", 2, "Max Number of possible masked to spawn in one level"); ZombieApocalypeModeConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Zombie Apocalypse Mode", "Zombie Apocalype Mode", false, "Only spawns Masked! Make sure to crank up the Max Spawn Count in this config! Would also recommend bringing a gun (mod), a shovel works fine too though.... This mode does not play nice with other mods that affect spawn rates. Disable those before playing for best results"); ZombieApocalypeRandomChanceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Zombie Apocalypse Mode", "Random Zombie Apocalype Mode", -1, "[Must Be Whole Number] The percent chance from 1 to 100 that a day could contain a zombie apocalypse. Put at -1 to never have the chance arise and don't have Only Spawn Masked turned on"); InsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "StartOfDay Inside Masked Spawn Curve", 0.1f, "Spawn curve for masked inside, start of the day. Crank this way up for immediate action. More info in the readme"); MiddayInsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "Midday Inside Masked Spawn Curve", 500f, "Spawn curve for masked inside, midday."); StartOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "StartOfDay Masked Outside Spawn Curve", -30f, "Spawn curve for outside masked, start of the day."); MidOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "Midday Outside Masked Spawn Curve", -30f, "Spawn curve for outside masked, midday."); EndOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "EOD Outside Masked Spawn Curve", 10f, "Spawn curve for outside masked, end of day"); RemoveMasks = RemoveMasksConfig.Value; UseVanillaSpawns = UseVanillaSpawnsConfig.Value; RemoveZombieArms = RemoveZombieArmsConfig.Value; UseSpawnRarity = UseSpawnRarityConfig.Value; CanSpawnOutside = CanSpawnOutsideConfig.Value; MaxSpawnCount = MaxSpawnCountConfig.Value; SpawnRarity = SpawnRarityConfig.Value; ZombieApocalypseMode = ZombieApocalypeModeConfig.Value; InsideEnemySpawnCurve = InsideEnemySpawnCurveConfig.Value; MiddayInsideEnemySpawnCurve = MiddayInsideEnemySpawnCurveConfig.Value; StartOutsideEnemySpawnCurve = StartOutsideEnemySpawnCurveConfig.Value; MidOutsideEnemySpawnCurve = MaxSpawnCountConfig.Value; EndOutsideEnemySpawnCurve = EndOutsideEnemySpawnCurveConfig.Value; RandomChanceZombieApocalypse = ZombieApocalypeRandomChanceConfig.Value; logger = Logger.CreateLogSource("MaskedEnemyRework"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MaskedEnemyRework is loaded! Woohoo!"); harmony.PatchAll(typeof(Plugin)); harmony.PatchAll(typeof(GetMaskedPrefabForLaterUse)); harmony.PatchAll(typeof(MaskedVisualRework)); harmony.PatchAll(typeof(MaskedSpawnSettings)); harmony.PatchAll(typeof(RemoveZombieArms)); } } public static class PluginInfo { public const string PLUGIN_GUID = "MaskedEnemyRework"; public const string PLUGIN_NAME = "MaskedEnemyRework"; public const string PLUGIN_VERSION = "2.1.0"; } } namespace MaskedEnemyRework.Patches { [HarmonyPatch(typeof(Terminal))] internal class GetMaskedPrefabForLaterUse { [HarmonyPatch("Start")] [HarmonyPostfix] private static void SavesPrefabForLaterUse(ref SelectableLevel[] ___moonsCatalogueList) { ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework"); SelectableLevel[] array = ___moonsCatalogueList; foreach (SelectableLevel val2 in array) { foreach (SpawnableEnemyWithRarity enemy in val2.Enemies) { if (enemy.enemyType.enemyName == "Masked") { val.LogInfo((object)"Found Masked!"); Plugin.maskedPrefab = enemy; } else if (enemy.enemyType.enemyName == "Flowerman") { Plugin.flowerPrefab = enemy; val.LogInfo((object)"Found Flowerman!"); } } } } } [HarmonyPatch(typeof(RoundManager))] internal class MaskedSpawnSettings { [HarmonyPatch("BeginEnemySpawning")] [HarmonyPrefix] private static void UpdateSpawnRates(ref SelectableLevel ___currentLevel) { //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Expected O, but got Unknown if (Plugin.UseVanillaSpawns) { return; } ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework"); val.LogInfo((object)"Starting Round Manager"); SpawnableEnemyWithRarity maskedPrefab = Plugin.maskedPrefab; SpawnableEnemyWithRarity val2 = Plugin.flowerPrefab; SelectableLevel obj = ___currentLevel; obj.maxEnemyPowerCount += maskedPrefab.enemyType.MaxCount; SelectableLevel obj2 = ___currentLevel; obj2.maxDaytimeEnemyPowerCount += maskedPrefab.enemyType.MaxCount; SelectableLevel obj3 = ___currentLevel; obj3.maxOutsideEnemyPowerCount += maskedPrefab.enemyType.MaxCount; List<SpawnableEnemyWithRarity> enemies = ___currentLevel.Enemies; for (int i = 0; i < ___currentLevel.Enemies.Count; i++) { SpawnableEnemyWithRarity val3 = ___currentLevel.Enemies[i]; if (val3.enemyType.enemyName == "Masked") { enemies.Remove(val3); } if (val3.enemyType.enemyName == "Flowerman") { val2 = val3; } } ___currentLevel.Enemies = enemies; maskedPrefab.enemyType.PowerLevel = 1; maskedPrefab.enemyType.probabilityCurve = val2.enemyType.probabilityCurve; if (Plugin.UseSpawnRarity) { maskedPrefab.rarity = Plugin.SpawnRarity; } else { maskedPrefab.rarity = val2.rarity; } maskedPrefab.enemyType.MaxCount = Plugin.MaxSpawnCount; maskedPrefab.enemyType.isOutsideEnemy = Plugin.CanSpawnOutside; int num = 0; num = ((StartOfRound.Instance.randomMapSeed.ToString().Length >= 3) ? int.Parse(StartOfRound.Instance.randomMapSeed.ToString().Substring(1, 2)) : 0); val.LogInfo((object)("Map seed " + num + " random chance " + Plugin.RandomChanceZombieApocalypse)); num = Mathf.Clamp(num, 0, 100); if (Plugin.ZombieApocalypseMode || (num <= Plugin.RandomChanceZombieApocalypse && Plugin.RandomChanceZombieApocalypse >= 0)) { val.LogInfo((object)"ZOMBIE APOCALYPSE"); ___currentLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, Plugin.InsideEnemySpawnCurve), new Keyframe(0.5f, Plugin.MiddayInsideEnemySpawnCurve) }); ___currentLevel.daytimeEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 7f), new Keyframe(0.5f, 7f) }); ___currentLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, Plugin.StartOutsideEnemySpawnCurve), new Keyframe(20f, Plugin.MidOutsideEnemySpawnCurve), new Keyframe(21f, Plugin.EndOutsideEnemySpawnCurve) }); ___currentLevel.DaytimeEnemies.Clear(); ___currentLevel.OutsideEnemies.Clear(); maskedPrefab.rarity = 1000000000; foreach (SpawnableEnemyWithRarity enemy in ___currentLevel.Enemies) { enemy.rarity = 0; } if (Plugin.CanSpawnOutside) { maskedPrefab.enemyType.isOutsideEnemy = true; ___currentLevel.OutsideEnemies.Add(maskedPrefab); ___currentLevel.DaytimeEnemies.Add(maskedPrefab); } } else { val.LogInfo((object)"no zombies :("); } ___currentLevel.Enemies.Add(maskedPrefab); } } [HarmonyPatch(typeof(MaskedPlayerEnemy))] internal class MaskedVisualRework { [HarmonyPatch("Start")] [HarmonyPostfix] private static void ReformVisuals(ref MaskedPlayerEnemy __instance) { ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework"); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; int num = StartOfRound.Instance.ClientPlayerList.Count; if (num == 0) { num = Random.Range(0, 2); val.LogInfo((object)"Player count was zero"); } int num2 = StartOfRound.Instance.randomMapSeed % num; val.LogInfo((object)("player count" + num)); val.LogInfo((object)("player index" + num2)); num2 = Mathf.Clamp(num2, 0, num); PlayerControllerB val2 = allPlayerScripts[num2]; __instance.mimickingPlayer = val2; __instance.SetSuit(val2.currentSuitID); if (Plugin.RemoveMasks) { ((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/HeadMaskComedy")).gameObject.SetActive(false); ((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/HeadMaskTragedy")).gameObject.SetActive(false); } } } internal class RemoveZombieArms { [HarmonyPatch(typeof(MaskedPlayerEnemy), "SetHandsOutClientRpc")] [HarmonyPrefix] private static void RemoveArms(ref bool setOut) { if (Plugin.RemoveZombieArms) { setOut = false; } } } }
plugins/MMHOOK/MMHOOK_Assembly-CSharp.dll
Decompiled 2 years ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Reflection; using DigitalRuby.ThunderAndLightning; using Discord; using Dissonance; using Dissonance.Integrations.Unity_NFGO; using DunGen; using DunGen.Adapters; using DunGen.Analysis; using DunGen.Editor; using DunGen.Graph; using DunGen.Tags; using GameNetcodeStuff; using MonoMod.Cil; using MonoMod.RuntimeDetour.HookGen; using On; using On.DigitalRuby.ThunderAndLightning; using On.Dissonance.Integrations.Unity_NFGO; using On.DunGen; using On.DunGen.Adapters; using On.DunGen.Analysis; using On.DunGen.Editor; using On.DunGen.Graph; using On.DunGen.Tags; using On.GameNetcodeStuff; using On.__GEN; using Steamworks; using Steamworks.Data; using TMPro; using Unity.AI.Navigation; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.Video; [assembly: AssemblyVersion("0.0.0.0")] namespace On { public static class AlarmButton { [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_PushAlarmButton(AlarmButton self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_PushAlarmButton(orig_PushAlarmButton orig, AlarmButton self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_Update(AlarmButton self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_Update(orig_Update orig, AlarmButton self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ctor(AlarmButton self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ctor(orig_ctor orig, AlarmButton self); public static event hook_PushAlarmButton PushAlarmButton { add { HookEndpointManager.Add<hook_PushAlarmButton>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_PushAlarmButton>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_Update Update { add { HookEndpointManager.Add<hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ctor ctor { add { HookEndpointManager.Add<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } } } namespace IL { public static class AlarmButton { public static event Manipulator PushAlarmButton { add { HookEndpointManager.Modify<On.AlarmButton.hook_PushAlarmButton>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AlarmButton.hook_PushAlarmButton>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator Update { add { HookEndpointManager.Modify<On.AlarmButton.hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AlarmButton.hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator ctor { add { HookEndpointManager.Modify<On.AlarmButton.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AlarmButton.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } } } namespace On { public static class AnimatedItem { [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_Start(AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_Start(orig_Start orig, AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_EquipItem(AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_EquipItem(orig_EquipItem orig, AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_DiscardItem(AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_DiscardItem(orig_DiscardItem orig, AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_PocketItem(AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_PocketItem(orig_PocketItem orig, AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_Update(AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_Update(orig_Update orig, AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ctor(AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ctor(orig_ctor orig, AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___initializeVariables(AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___initializeVariables(orig___initializeVariables orig, AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate string orig___getTypeName(AnimatedItem self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate string hook___getTypeName(orig___getTypeName orig, AnimatedItem self); public static event hook_Start Start { add { HookEndpointManager.Add<hook_Start>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_Start>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_EquipItem EquipItem { add { HookEndpointManager.Add<hook_EquipItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_EquipItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_DiscardItem DiscardItem { add { HookEndpointManager.Add<hook_DiscardItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_DiscardItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_PocketItem PocketItem { add { HookEndpointManager.Add<hook_PocketItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_PocketItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_Update Update { add { HookEndpointManager.Add<hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ctor ctor { add { HookEndpointManager.Add<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___initializeVariables __initializeVariables { add { HookEndpointManager.Add<hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___getTypeName __getTypeName { add { HookEndpointManager.Add<hook___getTypeName>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___getTypeName>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } } } namespace IL { public static class AnimatedItem { public static event Manipulator Start { add { HookEndpointManager.Modify<On.AnimatedItem.hook_Start>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedItem.hook_Start>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator EquipItem { add { HookEndpointManager.Modify<On.AnimatedItem.hook_EquipItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedItem.hook_EquipItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator DiscardItem { add { HookEndpointManager.Modify<On.AnimatedItem.hook_DiscardItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedItem.hook_DiscardItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator PocketItem { add { HookEndpointManager.Modify<On.AnimatedItem.hook_PocketItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedItem.hook_PocketItem>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator Update { add { HookEndpointManager.Modify<On.AnimatedItem.hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedItem.hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator ctor { add { HookEndpointManager.Modify<On.AnimatedItem.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedItem.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator __initializeVariables { add { HookEndpointManager.Modify<On.AnimatedItem.hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedItem.hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator __getTypeName { add { HookEndpointManager.Modify<On.AnimatedItem.hook___getTypeName>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedItem.hook___getTypeName>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } } } namespace On { public static class AnimatedTextureUV { [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_OnEnable(AnimatedTextureUV self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_OnEnable(orig_OnEnable orig, AnimatedTextureUV self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_OnDisable(AnimatedTextureUV self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_OnDisable(orig_OnDisable orig, AnimatedTextureUV self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate IEnumerator orig_AnimateUV(AnimatedTextureUV self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate IEnumerator hook_AnimateUV(orig_AnimateUV orig, AnimatedTextureUV self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ctor(AnimatedTextureUV self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ctor(orig_ctor orig, AnimatedTextureUV self); public static event hook_OnEnable OnEnable { add { HookEndpointManager.Add<hook_OnEnable>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_OnEnable>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_OnDisable OnDisable { add { HookEndpointManager.Add<hook_OnDisable>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_OnDisable>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_AnimateUV AnimateUV { add { HookEndpointManager.Add<hook_AnimateUV>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_AnimateUV>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ctor ctor { add { HookEndpointManager.Add<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } } } namespace IL { public static class AnimatedTextureUV { public static event Manipulator OnEnable { add { HookEndpointManager.Modify<On.AnimatedTextureUV.hook_OnEnable>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedTextureUV.hook_OnEnable>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator OnDisable { add { HookEndpointManager.Modify<On.AnimatedTextureUV.hook_OnDisable>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedTextureUV.hook_OnDisable>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator AnimateUV { add { HookEndpointManager.Modify<On.AnimatedTextureUV.hook_AnimateUV>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedTextureUV.hook_AnimateUV>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator ctor { add { HookEndpointManager.Modify<On.AnimatedTextureUV.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimatedTextureUV.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } } } namespace On { public static class AnimationStopPoints { [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetAnimationStopPosition1(AnimationStopPoints self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetAnimationStopPosition1(orig_SetAnimationStopPosition1 orig, AnimationStopPoints self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetAnimationGo(AnimationStopPoints self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetAnimationGo(orig_SetAnimationGo orig, AnimationStopPoints self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetAnimationStopPosition2(AnimationStopPoints self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetAnimationStopPosition2(orig_SetAnimationStopPosition2 orig, AnimationStopPoints self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ctor(AnimationStopPoints self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ctor(orig_ctor orig, AnimationStopPoints self); public static event hook_SetAnimationStopPosition1 SetAnimationStopPosition1 { add { HookEndpointManager.Add<hook_SetAnimationStopPosition1>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetAnimationStopPosition1>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SetAnimationGo SetAnimationGo { add { HookEndpointManager.Add<hook_SetAnimationGo>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetAnimationGo>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SetAnimationStopPosition2 SetAnimationStopPosition2 { add { HookEndpointManager.Add<hook_SetAnimationStopPosition2>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetAnimationStopPosition2>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ctor ctor { add { HookEndpointManager.Add<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } } } namespace IL { public static class AnimationStopPoints { public static event Manipulator SetAnimationStopPosition1 { add { HookEndpointManager.Modify<On.AnimationStopPoints.hook_SetAnimationStopPosition1>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimationStopPoints.hook_SetAnimationStopPosition1>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator SetAnimationGo { add { HookEndpointManager.Modify<On.AnimationStopPoints.hook_SetAnimationGo>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimationStopPoints.hook_SetAnimationGo>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator SetAnimationStopPosition2 { add { HookEndpointManager.Modify<On.AnimationStopPoints.hook_SetAnimationStopPosition2>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimationStopPoints.hook_SetAnimationStopPosition2>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator ctor { add { HookEndpointManager.Modify<On.AnimationStopPoints.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AnimationStopPoints.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } } } namespace On { public static class AudioReverbPresets { [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ctor(AudioReverbPresets self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ctor(orig_ctor orig, AudioReverbPresets self); public static event hook_ctor ctor { add { HookEndpointManager.Add<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } } } namespace IL { public static class AudioReverbPresets { public static event Manipulator ctor { add { HookEndpointManager.Modify<On.AudioReverbPresets.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AudioReverbPresets.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } } } namespace On { public static class AutoParentToShip { [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_Awake(AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_Awake(orig_Awake orig, AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_LateUpdate(AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_LateUpdate(orig_LateUpdate orig, AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartSuckingOutOfShip(AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartSuckingOutOfShip(orig_StartSuckingOutOfShip orig, AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate IEnumerator orig_SuckObjectOutOfShip(AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate IEnumerator hook_SuckObjectOutOfShip(orig_SuckObjectOutOfShip orig, AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_MoveToOffset(AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_MoveToOffset(orig_MoveToOffset orig, AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ctor(AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ctor(orig_ctor orig, AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___initializeVariables(AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___initializeVariables(orig___initializeVariables orig, AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate string orig___getTypeName(AutoParentToShip self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate string hook___getTypeName(orig___getTypeName orig, AutoParentToShip self); public static event hook_Awake Awake { add { HookEndpointManager.Add<hook_Awake>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_Awake>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_LateUpdate LateUpdate { add { HookEndpointManager.Add<hook_LateUpdate>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_LateUpdate>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartSuckingOutOfShip StartSuckingOutOfShip { add { HookEndpointManager.Add<hook_StartSuckingOutOfShip>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartSuckingOutOfShip>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SuckObjectOutOfShip SuckObjectOutOfShip { add { HookEndpointManager.Add<hook_SuckObjectOutOfShip>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SuckObjectOutOfShip>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_MoveToOffset MoveToOffset { add { HookEndpointManager.Add<hook_MoveToOffset>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_MoveToOffset>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ctor ctor { add { HookEndpointManager.Add<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___initializeVariables __initializeVariables { add { HookEndpointManager.Add<hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___getTypeName __getTypeName { add { HookEndpointManager.Add<hook___getTypeName>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___getTypeName>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } } } namespace IL { public static class AutoParentToShip { public static event Manipulator Awake { add { HookEndpointManager.Modify<On.AutoParentToShip.hook_Awake>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AutoParentToShip.hook_Awake>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator LateUpdate { add { HookEndpointManager.Modify<On.AutoParentToShip.hook_LateUpdate>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AutoParentToShip.hook_LateUpdate>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator StartSuckingOutOfShip { add { HookEndpointManager.Modify<On.AutoParentToShip.hook_StartSuckingOutOfShip>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AutoParentToShip.hook_StartSuckingOutOfShip>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator SuckObjectOutOfShip { add { HookEndpointManager.Modify<On.AutoParentToShip.hook_SuckObjectOutOfShip>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AutoParentToShip.hook_SuckObjectOutOfShip>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator MoveToOffset { add { HookEndpointManager.Modify<On.AutoParentToShip.hook_MoveToOffset>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AutoParentToShip.hook_MoveToOffset>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator ctor { add { HookEndpointManager.Modify<On.AutoParentToShip.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AutoParentToShip.hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator __initializeVariables { add { HookEndpointManager.Modify<On.AutoParentToShip.hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AutoParentToShip.hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } public static event Manipulator __getTypeName { add { HookEndpointManager.Modify<On.AutoParentToShip.hook___getTypeName>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } remove { HookEndpointManager.Unmodify<On.AutoParentToShip.hook___getTypeName>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)(object)value); } } } } namespace On { public static class BaboonBirdAI { [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_Start(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_Start(orig_Start orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SyncInitialValuesServerRpc(BaboonBirdAI self, int syncLeadershipLevel, Vector3 campPosition); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SyncInitialValuesServerRpc(orig_SyncInitialValuesServerRpc orig, BaboonBirdAI self, int syncLeadershipLevel, Vector3 campPosition); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SyncInitialValuesClientRpc(BaboonBirdAI self, int syncLeadershipLevel, Vector3 campPosition); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SyncInitialValuesClientRpc(orig_SyncInitialValuesClientRpc orig, BaboonBirdAI self, int syncLeadershipLevel, Vector3 campPosition); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_LateUpdate(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_LateUpdate(orig_LateUpdate orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_OnCollideWithPlayer(BaboonBirdAI self, Collider other); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_OnCollideWithPlayer(orig_OnCollideWithPlayer orig, BaboonBirdAI self, Collider other); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_OnCollideWithEnemy(BaboonBirdAI self, Collider other, EnemyAI enemyScript); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_OnCollideWithEnemy(orig_OnCollideWithEnemy orig, BaboonBirdAI self, Collider other, EnemyAI enemyScript); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_HitEnemy(BaboonBirdAI self, int force, PlayerControllerB playerWhoHit, bool playHitSFX); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_HitEnemy(orig_HitEnemy orig, BaboonBirdAI self, int force, PlayerControllerB playerWhoHit, bool playHitSFX); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_KillEnemy(BaboonBirdAI self, bool destroy); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_KillEnemy(orig_KillEnemy orig, BaboonBirdAI self, bool destroy); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StopKillAnimation(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StopKillAnimation(orig_StopKillAnimation orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StabPlayerDeathAnimServerRpc(BaboonBirdAI self, int playerObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StabPlayerDeathAnimServerRpc(orig_StabPlayerDeathAnimServerRpc orig, BaboonBirdAI self, int playerObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StabPlayerDeathAnimClientRpc(BaboonBirdAI self, int playerObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StabPlayerDeathAnimClientRpc(orig_StabPlayerDeathAnimClientRpc orig, BaboonBirdAI self, int playerObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate IEnumerator orig_killPlayerAnimation(BaboonBirdAI self, int playerObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate IEnumerator hook_killPlayerAnimation(orig_killPlayerAnimation orig, BaboonBirdAI self, int playerObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_InteractWithScrap(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_InteractWithScrap(orig_InteractWithScrap orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate bool orig_CanGrabScrap(BaboonBirdAI self, GrabbableObject scrap); [EditorBrowsable(EditorBrowsableState.Never)] public delegate bool hook_CanGrabScrap(orig_CanGrabScrap orig, BaboonBirdAI self, GrabbableObject scrap); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_DropHeldItemAndSync(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_DropHeldItemAndSync(orig_DropHeldItemAndSync orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_DropScrapServerRpc(BaboonBirdAI self, NetworkObjectReference item, Vector3 targetFloorPosition, int clientWhoSentRPC); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_DropScrapServerRpc(orig_DropScrapServerRpc orig, BaboonBirdAI self, NetworkObjectReference item, Vector3 targetFloorPosition, int clientWhoSentRPC); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_DropScrapClientRpc(BaboonBirdAI self, NetworkObjectReference item, Vector3 targetFloorPosition, int clientWhoSentRPC); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_DropScrapClientRpc(orig_DropScrapClientRpc orig, BaboonBirdAI self, NetworkObjectReference item, Vector3 targetFloorPosition, int clientWhoSentRPC); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_DropScrap(BaboonBirdAI self, NetworkObject item, Vector3 targetFloorPosition); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_DropScrap(orig_DropScrap orig, BaboonBirdAI self, NetworkObject item, Vector3 targetFloorPosition); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_GrabItemAndSync(BaboonBirdAI self, NetworkObject item); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_GrabItemAndSync(orig_GrabItemAndSync orig, BaboonBirdAI self, NetworkObject item); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_GrabScrapServerRpc(BaboonBirdAI self, NetworkObjectReference item, int clientWhoSentRPC); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_GrabScrapServerRpc(orig_GrabScrapServerRpc orig, BaboonBirdAI self, NetworkObjectReference item, int clientWhoSentRPC); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_GrabScrapClientRpc(BaboonBirdAI self, NetworkObjectReference item, int clientWhoSentRPC); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_GrabScrapClientRpc(orig_GrabScrapClientRpc orig, BaboonBirdAI self, NetworkObjectReference item, int clientWhoSentRPC); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_GrabScrap(BaboonBirdAI self, NetworkObject item); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_GrabScrap(orig_GrabScrap orig, BaboonBirdAI self, NetworkObject item); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ReachedNodeInSearch(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ReachedNodeInSearch(orig_ReachedNodeInSearch orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_DoAIInterval(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_DoAIInterval(orig_DoAIInterval orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StopFocusingThreat(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StopFocusingThreat(orig_StopFocusingThreat orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StopFocusingThreatServerRpc(BaboonBirdAI self, bool enterScoutingMode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StopFocusingThreatServerRpc(orig_StopFocusingThreatServerRpc orig, BaboonBirdAI self, bool enterScoutingMode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StopFocusingThreatClientRpc(BaboonBirdAI self, bool enterScoutingMode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StopFocusingThreatClientRpc(orig_StopFocusingThreatClientRpc orig, BaboonBirdAI self, bool enterScoutingMode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetAggressiveMode(BaboonBirdAI self, int mode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetAggressiveMode(orig_SetAggressiveMode orig, BaboonBirdAI self, int mode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetAggressiveModeServerRpc(BaboonBirdAI self, int mode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetAggressiveModeServerRpc(orig_SetAggressiveModeServerRpc orig, BaboonBirdAI self, int mode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetAggressiveModeClientRpc(BaboonBirdAI self, int mode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetAggressiveModeClientRpc(orig_SetAggressiveModeClientRpc orig, BaboonBirdAI self, int mode); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetThreatInView(BaboonBirdAI self, bool inView); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetThreatInView(orig_SetThreatInView orig, BaboonBirdAI self, bool inView); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetThreatInViewServerRpc(BaboonBirdAI self, bool inView); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetThreatInViewServerRpc(orig_SetThreatInViewServerRpc orig, BaboonBirdAI self, bool inView); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_SetThreatInViewClientRpc(BaboonBirdAI self, bool inView); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_SetThreatInViewClientRpc(orig_SetThreatInViewClientRpc orig, BaboonBirdAI self, bool inView); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_EnemyEnterRestModeServerRpc(BaboonBirdAI self, bool sleep, bool atCamp); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_EnemyEnterRestModeServerRpc(orig_EnemyEnterRestModeServerRpc orig, BaboonBirdAI self, bool sleep, bool atCamp); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_EnemyEnterRestModeClientRpc(BaboonBirdAI self, bool sleep, bool atCamp); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_EnemyEnterRestModeClientRpc(orig_EnemyEnterRestModeClientRpc orig, BaboonBirdAI self, bool sleep, bool atCamp); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_EnemyGetUpServerRpc(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_EnemyGetUpServerRpc(orig_EnemyGetUpServerRpc orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_EnemyGetUpClientRpc(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_EnemyGetUpClientRpc(orig_EnemyGetUpClientRpc orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_OnDrawGizmos(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_OnDrawGizmos(orig_OnDrawGizmos orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_DetectNoise(BaboonBirdAI self, Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_DetectNoise(orig_DetectNoise orig, BaboonBirdAI self, Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_AnimateLooking(BaboonBirdAI self, Vector3 lookAtPosition); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_AnimateLooking(orig_AnimateLooking orig, BaboonBirdAI self, Vector3 lookAtPosition); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_Update(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_Update(orig_Update orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate float orig_GetComfortableDistanceToThreat(BaboonBirdAI self, Threat focusedThreat); [EditorBrowsable(EditorBrowsableState.Never)] public delegate float hook_GetComfortableDistanceToThreat(orig_GetComfortableDistanceToThreat orig, BaboonBirdAI self, Threat focusedThreat); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ReactToThreat(BaboonBirdAI self, Threat closestThreat); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ReactToThreat(orig_ReactToThreat orig, BaboonBirdAI self, Threat closestThreat); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartFocusOnThreatServerRpc(BaboonBirdAI self, NetworkObjectReference netObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartFocusOnThreatServerRpc(orig_StartFocusOnThreatServerRpc orig, BaboonBirdAI self, NetworkObjectReference netObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartFocusOnThreatClientRpc(BaboonBirdAI self, NetworkObjectReference netObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartFocusOnThreatClientRpc(orig_StartFocusOnThreatClientRpc orig, BaboonBirdAI self, NetworkObjectReference netObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate float orig_ReactToOtherBaboonSighted(BaboonBirdAI self, BaboonBirdAI otherBaboon); [EditorBrowsable(EditorBrowsableState.Never)] public delegate float hook_ReactToOtherBaboonSighted(orig_ReactToOtherBaboonSighted orig, BaboonBirdAI self, BaboonBirdAI otherBaboon); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_DoLOSCheck(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_DoLOSCheck(orig_DoLOSCheck orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_PingBaboonInterest(BaboonBirdAI self, Vector3 interestPosition, int pingImportance); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_PingBaboonInterest(orig_PingBaboonInterest orig, BaboonBirdAI self, Vector3 interestPosition, int pingImportance); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_PingBirdInterestServerRpc(BaboonBirdAI self, Vector3 lookPosition, float timeToPeek); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_PingBirdInterestServerRpc(orig_PingBirdInterestServerRpc orig, BaboonBirdAI self, Vector3 lookPosition, float timeToPeek); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_PingBirdInterestClientRpc(BaboonBirdAI self, Vector3 lookPosition, float timeToPeek); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_PingBirdInterestClientRpc(orig_PingBirdInterestClientRpc orig, BaboonBirdAI self, Vector3 lookPosition, float timeToPeek); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_JoinScoutingGroup(BaboonBirdAI self, BaboonBirdAI otherBaboon); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_JoinScoutingGroup(orig_JoinScoutingGroup orig, BaboonBirdAI self, BaboonBirdAI otherBaboon); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartScoutingGroup(BaboonBirdAI self, BaboonBirdAI firstMember, bool syncWithClients); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartScoutingGroup(orig_StartScoutingGroup orig, BaboonBirdAI self, BaboonBirdAI firstMember, bool syncWithClients); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_LeaveCurrentScoutingGroup(BaboonBirdAI self, bool sync); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_LeaveCurrentScoutingGroup(orig_LeaveCurrentScoutingGroup orig, BaboonBirdAI self, bool sync); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_LeaveScoutingGroupServerRpc(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_LeaveScoutingGroupServerRpc(orig_LeaveScoutingGroupServerRpc orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_LeaveScoutingGroupClientRpc(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_LeaveScoutingGroupClientRpc(orig_LeaveScoutingGroupClientRpc orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartScoutingGroupServerRpc(BaboonBirdAI self, NetworkObjectReference leaderNetworkObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartScoutingGroupServerRpc(orig_StartScoutingGroupServerRpc orig, BaboonBirdAI self, NetworkObjectReference leaderNetworkObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartScoutingGroupClientRpc(BaboonBirdAI self, NetworkObjectReference leaderNetworkObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartScoutingGroupClientRpc(orig_StartScoutingGroupClientRpc orig, BaboonBirdAI self, NetworkObjectReference leaderNetworkObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_JoinScoutingGroupServerRpc(BaboonBirdAI self, NetworkObjectReference otherBaboonNetworkObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_JoinScoutingGroupServerRpc(orig_JoinScoutingGroupServerRpc orig, BaboonBirdAI self, NetworkObjectReference otherBaboonNetworkObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_JoinScoutingGroupClientRpc(BaboonBirdAI self, NetworkObjectReference otherBaboonNetworkObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_JoinScoutingGroupClientRpc(orig_JoinScoutingGroupClientRpc orig, BaboonBirdAI self, NetworkObjectReference otherBaboonNetworkObject); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_CallToOtherBaboon(BaboonBirdAI self, BaboonBirdAI otherBaboon); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_CallToOtherBaboon(orig_CallToOtherBaboon orig, BaboonBirdAI self, BaboonBirdAI otherBaboon); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartMiscAnimation(BaboonBirdAI self, int anim); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartMiscAnimation(orig_StartMiscAnimation orig, BaboonBirdAI self, int anim); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartMiscAnimationServerRpc(BaboonBirdAI self, int miscAnimationId); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartMiscAnimationServerRpc(orig_StartMiscAnimationServerRpc orig, BaboonBirdAI self, int miscAnimationId); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_StartMiscAnimationClientRpc(BaboonBirdAI self, int miscAnimationId); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_StartMiscAnimationClientRpc(orig_StartMiscAnimationClientRpc orig, BaboonBirdAI self, int miscAnimationId); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_CalculateAnimationDirection(BaboonBirdAI self, float maxSpeed); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_CalculateAnimationDirection(orig_CalculateAnimationDirection orig, BaboonBirdAI self, float maxSpeed); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_ctor(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_ctor(orig_ctor orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___initializeVariables(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___initializeVariables(orig___initializeVariables orig, BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig_InitializeRPCS_BaboonBirdAI(); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook_InitializeRPCS_BaboonBirdAI(orig_InitializeRPCS_BaboonBirdAI orig); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3452382367(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3452382367(orig___rpc_handler_3452382367 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3856685904(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3856685904(orig___rpc_handler_3856685904 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_2476579270(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_2476579270(orig___rpc_handler_2476579270 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3749667856(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3749667856(orig___rpc_handler_3749667856 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1418775270(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1418775270(orig___rpc_handler_1418775270 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1865475504(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1865475504(orig___rpc_handler_1865475504 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_869682226(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_869682226(orig___rpc_handler_869682226 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1564051222(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1564051222(orig___rpc_handler_1564051222 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1546030380(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1546030380(orig___rpc_handler_1546030380 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3360048400(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3360048400(orig___rpc_handler_3360048400 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_443869275(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_443869275(orig___rpc_handler_443869275 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1782649174(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1782649174(orig___rpc_handler_1782649174 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3428942850(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3428942850(orig___rpc_handler_3428942850 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_2073937320(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_2073937320(orig___rpc_handler_2073937320 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1806580287(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1806580287(orig___rpc_handler_1806580287 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1567928363(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1567928363(orig___rpc_handler_1567928363 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3614203845(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3614203845(orig___rpc_handler_3614203845 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1155909339(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1155909339(orig___rpc_handler_1155909339 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3933590138(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3933590138(orig___rpc_handler_3933590138 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_991811456(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_991811456(orig___rpc_handler_991811456 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1670979535(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1670979535(orig___rpc_handler_1670979535 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_2348332192(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_2348332192(orig___rpc_handler_2348332192 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_2459653399(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_2459653399(orig___rpc_handler_2459653399 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_696889160(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_696889160(orig___rpc_handler_696889160 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3367846835(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3367846835(orig___rpc_handler_3367846835 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1737299197(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1737299197(orig___rpc_handler_1737299197 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1775372234(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1775372234(orig___rpc_handler_1775372234 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1078565091(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1078565091(orig___rpc_handler_1078565091 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_1580405641(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_1580405641(orig___rpc_handler_1580405641 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void orig___rpc_handler_3995026000(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate void hook___rpc_handler_3995026000(orig___rpc_handler_3995026000 orig, NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams); [EditorBrowsable(EditorBrowsableState.Never)] public delegate string orig___getTypeName(BaboonBirdAI self); [EditorBrowsable(EditorBrowsableState.Never)] public delegate string hook___getTypeName(orig___getTypeName orig, BaboonBirdAI self); public static event hook_Start Start { add { HookEndpointManager.Add<hook_Start>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_Start>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SyncInitialValuesServerRpc SyncInitialValuesServerRpc { add { HookEndpointManager.Add<hook_SyncInitialValuesServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SyncInitialValuesServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SyncInitialValuesClientRpc SyncInitialValuesClientRpc { add { HookEndpointManager.Add<hook_SyncInitialValuesClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SyncInitialValuesClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_LateUpdate LateUpdate { add { HookEndpointManager.Add<hook_LateUpdate>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_LateUpdate>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_OnCollideWithPlayer OnCollideWithPlayer { add { HookEndpointManager.Add<hook_OnCollideWithPlayer>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_OnCollideWithPlayer>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_OnCollideWithEnemy OnCollideWithEnemy { add { HookEndpointManager.Add<hook_OnCollideWithEnemy>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_OnCollideWithEnemy>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_HitEnemy HitEnemy { add { HookEndpointManager.Add<hook_HitEnemy>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_HitEnemy>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_KillEnemy KillEnemy { add { HookEndpointManager.Add<hook_KillEnemy>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_KillEnemy>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StopKillAnimation StopKillAnimation { add { HookEndpointManager.Add<hook_StopKillAnimation>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StopKillAnimation>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StabPlayerDeathAnimServerRpc StabPlayerDeathAnimServerRpc { add { HookEndpointManager.Add<hook_StabPlayerDeathAnimServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StabPlayerDeathAnimServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StabPlayerDeathAnimClientRpc StabPlayerDeathAnimClientRpc { add { HookEndpointManager.Add<hook_StabPlayerDeathAnimClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StabPlayerDeathAnimClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_killPlayerAnimation killPlayerAnimation { add { HookEndpointManager.Add<hook_killPlayerAnimation>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_killPlayerAnimation>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_InteractWithScrap InteractWithScrap { add { HookEndpointManager.Add<hook_InteractWithScrap>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_InteractWithScrap>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_CanGrabScrap CanGrabScrap { add { HookEndpointManager.Add<hook_CanGrabScrap>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_CanGrabScrap>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_DropHeldItemAndSync DropHeldItemAndSync { add { HookEndpointManager.Add<hook_DropHeldItemAndSync>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_DropHeldItemAndSync>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_DropScrapServerRpc DropScrapServerRpc { add { HookEndpointManager.Add<hook_DropScrapServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_DropScrapServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_DropScrapClientRpc DropScrapClientRpc { add { HookEndpointManager.Add<hook_DropScrapClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_DropScrapClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_DropScrap DropScrap { add { HookEndpointManager.Add<hook_DropScrap>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_DropScrap>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_GrabItemAndSync GrabItemAndSync { add { HookEndpointManager.Add<hook_GrabItemAndSync>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_GrabItemAndSync>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_GrabScrapServerRpc GrabScrapServerRpc { add { HookEndpointManager.Add<hook_GrabScrapServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_GrabScrapServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_GrabScrapClientRpc GrabScrapClientRpc { add { HookEndpointManager.Add<hook_GrabScrapClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_GrabScrapClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_GrabScrap GrabScrap { add { HookEndpointManager.Add<hook_GrabScrap>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_GrabScrap>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ReachedNodeInSearch ReachedNodeInSearch { add { HookEndpointManager.Add<hook_ReachedNodeInSearch>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ReachedNodeInSearch>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_DoAIInterval DoAIInterval { add { HookEndpointManager.Add<hook_DoAIInterval>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_DoAIInterval>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StopFocusingThreat StopFocusingThreat { add { HookEndpointManager.Add<hook_StopFocusingThreat>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StopFocusingThreat>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StopFocusingThreatServerRpc StopFocusingThreatServerRpc { add { HookEndpointManager.Add<hook_StopFocusingThreatServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StopFocusingThreatServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StopFocusingThreatClientRpc StopFocusingThreatClientRpc { add { HookEndpointManager.Add<hook_StopFocusingThreatClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StopFocusingThreatClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SetAggressiveMode SetAggressiveMode { add { HookEndpointManager.Add<hook_SetAggressiveMode>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetAggressiveMode>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SetAggressiveModeServerRpc SetAggressiveModeServerRpc { add { HookEndpointManager.Add<hook_SetAggressiveModeServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetAggressiveModeServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SetAggressiveModeClientRpc SetAggressiveModeClientRpc { add { HookEndpointManager.Add<hook_SetAggressiveModeClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetAggressiveModeClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SetThreatInView SetThreatInView { add { HookEndpointManager.Add<hook_SetThreatInView>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetThreatInView>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SetThreatInViewServerRpc SetThreatInViewServerRpc { add { HookEndpointManager.Add<hook_SetThreatInViewServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetThreatInViewServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_SetThreatInViewClientRpc SetThreatInViewClientRpc { add { HookEndpointManager.Add<hook_SetThreatInViewClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_SetThreatInViewClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_EnemyEnterRestModeServerRpc EnemyEnterRestModeServerRpc { add { HookEndpointManager.Add<hook_EnemyEnterRestModeServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_EnemyEnterRestModeServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_EnemyEnterRestModeClientRpc EnemyEnterRestModeClientRpc { add { HookEndpointManager.Add<hook_EnemyEnterRestModeClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_EnemyEnterRestModeClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_EnemyGetUpServerRpc EnemyGetUpServerRpc { add { HookEndpointManager.Add<hook_EnemyGetUpServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_EnemyGetUpServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_EnemyGetUpClientRpc EnemyGetUpClientRpc { add { HookEndpointManager.Add<hook_EnemyGetUpClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_EnemyGetUpClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_OnDrawGizmos OnDrawGizmos { add { HookEndpointManager.Add<hook_OnDrawGizmos>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_OnDrawGizmos>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_DetectNoise DetectNoise { add { HookEndpointManager.Add<hook_DetectNoise>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_DetectNoise>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_AnimateLooking AnimateLooking { add { HookEndpointManager.Add<hook_AnimateLooking>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_AnimateLooking>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_Update Update { add { HookEndpointManager.Add<hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_Update>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_GetComfortableDistanceToThreat GetComfortableDistanceToThreat { add { HookEndpointManager.Add<hook_GetComfortableDistanceToThreat>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_GetComfortableDistanceToThreat>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ReactToThreat ReactToThreat { add { HookEndpointManager.Add<hook_ReactToThreat>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ReactToThreat>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartFocusOnThreatServerRpc StartFocusOnThreatServerRpc { add { HookEndpointManager.Add<hook_StartFocusOnThreatServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartFocusOnThreatServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartFocusOnThreatClientRpc StartFocusOnThreatClientRpc { add { HookEndpointManager.Add<hook_StartFocusOnThreatClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartFocusOnThreatClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ReactToOtherBaboonSighted ReactToOtherBaboonSighted { add { HookEndpointManager.Add<hook_ReactToOtherBaboonSighted>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ReactToOtherBaboonSighted>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_DoLOSCheck DoLOSCheck { add { HookEndpointManager.Add<hook_DoLOSCheck>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_DoLOSCheck>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_PingBaboonInterest PingBaboonInterest { add { HookEndpointManager.Add<hook_PingBaboonInterest>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_PingBaboonInterest>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_PingBirdInterestServerRpc PingBirdInterestServerRpc { add { HookEndpointManager.Add<hook_PingBirdInterestServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_PingBirdInterestServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_PingBirdInterestClientRpc PingBirdInterestClientRpc { add { HookEndpointManager.Add<hook_PingBirdInterestClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_PingBirdInterestClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_JoinScoutingGroup JoinScoutingGroup { add { HookEndpointManager.Add<hook_JoinScoutingGroup>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_JoinScoutingGroup>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartScoutingGroup StartScoutingGroup { add { HookEndpointManager.Add<hook_StartScoutingGroup>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartScoutingGroup>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_LeaveCurrentScoutingGroup LeaveCurrentScoutingGroup { add { HookEndpointManager.Add<hook_LeaveCurrentScoutingGroup>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_LeaveCurrentScoutingGroup>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_LeaveScoutingGroupServerRpc LeaveScoutingGroupServerRpc { add { HookEndpointManager.Add<hook_LeaveScoutingGroupServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_LeaveScoutingGroupServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_LeaveScoutingGroupClientRpc LeaveScoutingGroupClientRpc { add { HookEndpointManager.Add<hook_LeaveScoutingGroupClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_LeaveScoutingGroupClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartScoutingGroupServerRpc StartScoutingGroupServerRpc { add { HookEndpointManager.Add<hook_StartScoutingGroupServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartScoutingGroupServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartScoutingGroupClientRpc StartScoutingGroupClientRpc { add { HookEndpointManager.Add<hook_StartScoutingGroupClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartScoutingGroupClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_JoinScoutingGroupServerRpc JoinScoutingGroupServerRpc { add { HookEndpointManager.Add<hook_JoinScoutingGroupServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_JoinScoutingGroupServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_JoinScoutingGroupClientRpc JoinScoutingGroupClientRpc { add { HookEndpointManager.Add<hook_JoinScoutingGroupClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_JoinScoutingGroupClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_CallToOtherBaboon CallToOtherBaboon { add { HookEndpointManager.Add<hook_CallToOtherBaboon>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_CallToOtherBaboon>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartMiscAnimation StartMiscAnimation { add { HookEndpointManager.Add<hook_StartMiscAnimation>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartMiscAnimation>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartMiscAnimationServerRpc StartMiscAnimationServerRpc { add { HookEndpointManager.Add<hook_StartMiscAnimationServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartMiscAnimationServerRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_StartMiscAnimationClientRpc StartMiscAnimationClientRpc { add { HookEndpointManager.Add<hook_StartMiscAnimationClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_StartMiscAnimationClientRpc>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_CalculateAnimationDirection CalculateAnimationDirection { add { HookEndpointManager.Add<hook_CalculateAnimationDirection>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_CalculateAnimationDirection>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_ctor ctor { add { HookEndpointManager.Add<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_ctor>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___initializeVariables __initializeVariables { add { HookEndpointManager.Add<hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___initializeVariables>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook_InitializeRPCS_BaboonBirdAI InitializeRPCS_BaboonBirdAI { add { HookEndpointManager.Add<hook_InitializeRPCS_BaboonBirdAI>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook_InitializeRPCS_BaboonBirdAI>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_3452382367 __rpc_handler_3452382367 { add { HookEndpointManager.Add<hook___rpc_handler_3452382367>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_3452382367>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_3856685904 __rpc_handler_3856685904 { add { HookEndpointManager.Add<hook___rpc_handler_3856685904>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_3856685904>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_2476579270 __rpc_handler_2476579270 { add { HookEndpointManager.Add<hook___rpc_handler_2476579270>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_2476579270>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_3749667856 __rpc_handler_3749667856 { add { HookEndpointManager.Add<hook___rpc_handler_3749667856>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_3749667856>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_1418775270 __rpc_handler_1418775270 { add { HookEndpointManager.Add<hook___rpc_handler_1418775270>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_1418775270>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_1865475504 __rpc_handler_1865475504 { add { HookEndpointManager.Add<hook___rpc_handler_1865475504>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_1865475504>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_869682226 __rpc_handler_869682226 { add { HookEndpointManager.Add<hook___rpc_handler_869682226>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_869682226>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_1564051222 __rpc_handler_1564051222 { add { HookEndpointManager.Add<hook___rpc_handler_1564051222>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_1564051222>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_1546030380 __rpc_handler_1546030380 { add { HookEndpointManager.Add<hook___rpc_handler_1546030380>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_1546030380>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_3360048400 __rpc_handler_3360048400 { add { HookEndpointManager.Add<hook___rpc_handler_3360048400>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_3360048400>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_443869275 __rpc_handler_443869275 { add { HookEndpointManager.Add<hook___rpc_handler_443869275>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_443869275>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_1782649174 __rpc_handler_1782649174 { add { HookEndpointManager.Add<hook___rpc_handler_1782649174>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } remove { HookEndpointManager.Remove<hook___rpc_handler_1782649174>(MethodBase.GetMethodFromHandle((RuntimeMethodHandle)/*OpCode not supported: LdMemberToken*/), (Delegate)value); } } public static event hook___rpc_handler_3428942850 __rpc_handler_3428942850
plugins/MoreDeathNotes.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Coroner.LCAPI; using GameNetcodeStuff; using HarmonyLib; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using TMPro; 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("AnythingGoesGit")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Update the Performance Report to include new information, such as the cause of death.")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0")] [assembly: AssemblyProduct("MoreDeathNotes")] [assembly: AssemblyTitle("MoreDeathNotes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.0.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 Coroner { internal class AdvancedDeathTracker { public const int PLAYER_CAUSE_OF_DEATH_DROPSHIP = 300; public static readonly string[] FUNNY_NOTES = new string[41] { "The goofiest goober.", "The cutest employee.", "Had the most fun.", "Had the least fun.", "The bravest employee.", "Did a sick flip.", "Stubbed their toe.", "The most likely to die next time.", "The least likely to die next time.", "Dislikes smoke.", "A team player.", "A real go-getter.", "Ate the most snacks.", "Passed GO and collected $200.", "Got freaky on a Friday night.", "I think this one's a serial killer.", "Perfectly unremarkable.", "Hasn't called their mother in a while.", "Has IP address 127.0.0.1.", "Secretly a lizard", "Believed they could fly.", "Thought they had nine lives.", "Believes in Santa Claus.", "Still uses a flip phone.", "Can't cook instant noodles right.", "Thinks the Earth is flat.", "Still afraid of the dark.", "Always the first in line for coffee.", "Lost a bet with a parrot.", "Can't remember their passwords.", "Secretly a superhero on weekends.", "Tried to high-five a mirror.", "Thinks pineapple belongs on pizza.", "Never finishes their... ", "Talks to plants.", "Has a pet rock named Steve.", "Wanted to be an astronaut.", "Sleeps with a night light.", "Once got stuck in a revolving door.", "Has a collection of rubber ducks.", "Dances when no one is watching." }; private static readonly Dictionary<int, AdvancedCauseOfDeath> PlayerCauseOfDeath = new Dictionary<int, AdvancedCauseOfDeath>(); private static readonly Dictionary<int, string> PlayerNotes = new Dictionary<int, string>(); public static void ClearDeathTracker() { PlayerCauseOfDeath.Clear(); PlayerNotes.Clear(); } public static void SetCauseOfDeath(int playerIndex, AdvancedCauseOfDeath causeOfDeath, bool broadcast = true) { PlayerCauseOfDeath[playerIndex] = causeOfDeath; if (broadcast) { DeathBroadcaster.BroadcastCauseOfDeath(playerIndex, causeOfDeath); } } public static void SetCauseOfDeath(int playerIndex, CauseOfDeath causeOfDeath, bool broadcast = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SetCauseOfDeath(playerIndex, ConvertCauseOfDeath(causeOfDeath), broadcast); } public static void SetCauseOfDeath(PlayerControllerB playerController, CauseOfDeath causeOfDeath, bool broadcast = true) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) SetCauseOfDeath((int)playerController.playerClientId, ConvertCauseOfDeath(causeOfDeath), broadcast); } public static void SetCauseOfDeath(PlayerControllerB playerController, AdvancedCauseOfDeath causeOfDeath, bool broadcast = true) { SetCauseOfDeath((int)playerController.playerClientId, causeOfDeath, broadcast); } public static AdvancedCauseOfDeath GetCauseOfDeath(int playerIndex) { return GetCauseOfDeath(StartOfRound.Instance.allPlayerScripts[playerIndex]); } public static AdvancedCauseOfDeath GetCauseOfDeath(PlayerControllerB playerController) { if (!PlayerCauseOfDeath.ContainsKey((int)playerController.playerClientId)) { Plugin.Instance.PluginLogger.LogDebug((object)$"Player {playerController.playerClientId} has no custom cause of death stored! Using fallback..."); return GuessCauseOfDeath(playerController); } Plugin.Instance.PluginLogger.LogDebug((object)$"Player {playerController.playerClientId} has custom cause of death stored! {PlayerCauseOfDeath[(int)playerController.playerClientId]}"); return PlayerCauseOfDeath[(int)playerController.playerClientId]; } public static AdvancedCauseOfDeath GuessCauseOfDeath(PlayerControllerB playerController) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if (playerController.isPlayerDead) { if (IsHoldingJetpack(playerController)) { if ((int)playerController.causeOfDeath == 2) { return AdvancedCauseOfDeath.Player_Jetpack_Gravity; } if ((int)playerController.causeOfDeath == 3) { return AdvancedCauseOfDeath.Player_Jetpack_Blast; } } return ConvertCauseOfDeath(playerController.causeOfDeath); } return AdvancedCauseOfDeath.Unknown; } public static bool IsHoldingJetpack(PlayerControllerB playerController) { GrabbableObject currentlyHeldObjectServer = playerController.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer == (Object)null) { return false; } GameObject gameObject = ((Component)currentlyHeldObjectServer).gameObject; if ((Object)(object)gameObject == (Object)null) { return false; } GrabbableObject component = gameObject.GetComponent<GrabbableObject>(); if ((Object)(object)component == (Object)null) { return false; } if (component is JetpackItem) { return true; } return false; } public static AdvancedCauseOfDeath ConvertCauseOfDeath(CauseOfDeath causeOfDeath) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected I4, but got Unknown return (int)causeOfDeath switch { 0 => AdvancedCauseOfDeath.Unknown, 1 => AdvancedCauseOfDeath.Bludgeoning, 2 => AdvancedCauseOfDeath.Gravity, 3 => AdvancedCauseOfDeath.Blast, 4 => AdvancedCauseOfDeath.Strangulation, 5 => AdvancedCauseOfDeath.Suffocation, 6 => AdvancedCauseOfDeath.Mauling, 7 => AdvancedCauseOfDeath.Gunshots, 8 => AdvancedCauseOfDeath.Crushing, 9 => AdvancedCauseOfDeath.Drowning, 10 => AdvancedCauseOfDeath.Abandoned, 11 => AdvancedCauseOfDeath.Electrocution, _ => AdvancedCauseOfDeath.Unknown, }; } public static string StringifyCauseOfDeath(CauseOfDeath causeOfDeath) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return StringifyCauseOfDeath(ConvertCauseOfDeath(causeOfDeath), Plugin.RANDOM); } public static string StringifyCauseOfDeath(AdvancedCauseOfDeath? causeOfDeath) { return StringifyCauseOfDeath(causeOfDeath, Plugin.RANDOM); } public static string StringifyCauseOfDeath(AdvancedCauseOfDeath? causeOfDeath, Random random) { string[] array = SelectCauseOfDeath(causeOfDeath); if (array.Length == 1 || Plugin.Instance.PluginConfig.ShouldUseSeriousDeathMessages()) { return array[0]; } return array[random.Next(array.Length)]; } public static string[] SelectCauseOfDeath(AdvancedCauseOfDeath? causeOfDeath) { if (!causeOfDeath.HasValue) { return FUNNY_NOTES; } return causeOfDeath switch { AdvancedCauseOfDeath.Bludgeoning => new string[10] { "Bludgeoned to death.", "Met the business end of a hammer.", "Learned that gravity and rocks don't mix.", "Discovered why pillows are safer than bricks.", "Took a hard hit, literally.", "Found out hammers aren't just for nails.", "Tried to catch a falling anvil.", "Wrestled with a rock and the rock won.", "Received a heavy dose of blunt force trauma.", "Had an unexpected rendezvous with a bat." }, AdvancedCauseOfDeath.Gravity => new string[10] { "Fell to their death.", "Fell off a cliff.", "Discovered flying isn't for everyone.", "Took a dive, forgot to stop.", "Learned that what goes up must come down.", "Gravity: 1, Common Sense: 0.", "Had a falling out with the ground.", "Tried skydiving without a parachute.", "Did not stick the landing.", "Was a victim of the law of gravity." }, AdvancedCauseOfDeath.Blast => new string[10] { "Went out with a bang.", "Exploded.", "Was blown to smithereens.", "Tried to juggle grenades.", "Learned the hard way that red barrels explode.", "Found out bombs are not toys.", "Misunderstood the 'keep away from fire' warning.", "Had a blast, but not in a good way.", "Went out in a blaze of glory.", "Had an explosive personality." }, AdvancedCauseOfDeath.Strangulation => new string[10] { "Strangled to death.", "Tried to swallow a boa constrictor.", "Underestimated the strength of a necktie.", "Took a chokehold way too seriously.", "Tried a scarf, found it a bit too tight.", "Played a deadly game of tug-o-war with a python.", "Tried to deep throat a rope.", "Realized too late that 'breath play' is not for everyone.", "Found out the hard way that neck massages can be deadly.", "Discovered that some necklaces are too tight." }, AdvancedCauseOfDeath.Suffocation => new string[10] { "Suffocated to death.", "Forgot how to breathe.", "Played hide and seek in a vacuum.", "Took a deadly nap in a plastic bag.", "Tried to hold their breath indefinitely.", "Got a little too intimate with a pillow.", "Misplaced their oxygen.", "Found out that vacuum cleaners are not for internal use.", "Thought they could breathe underwater without equipment.", "Didn't believe in the concept of breathing." }, AdvancedCauseOfDeath.Mauling => new string[10] { "Mauled to death.", "Tried to pet a bear.", "Played fetch with a lion.", "Thought they could outrun a cheetah.", "Discovered too late that 'do not feed the animals' was a suggestion.", "Tried to take a selfie with a tiger.", "Decided to go for a midnight stroll in a wolf-infested forest.", "Realized too late that 'playing dead' doesn't work with grizzly bears.", "Found out the hard way that you can't tame a wild beast with a steak.", "Got a little too close to nature." }, AdvancedCauseOfDeath.Gunshots => new string[10] { "Shot to death by a turret.", "Caught a bullet with their name on it.", "Played dodgeball with bullets and lost.", "Realized they weren't faster than a speeding bullet.", "Learned that gunfights are not like the movies.", "Found out what 'bullet time' really means.", "Discovered that shooting stars can be lethal.", "Took 'biting the bullet' too literally.", "Had a fatal attraction to flying lead.", "Learned the hard way that bullets are bad for health." }, AdvancedCauseOfDeath.Crushing => new string[10] { "Crushed to death.", "Had a smashing time, literally.", "Played rock-paper-scissors with a boulder.", "Discovered that walls can hug too tightly.", "Found out that heavy lifting can be fatal.", "Learned that ceilings can drop without notice.", "Got a bit too close to a compactor.", "Tried to fight gravity, and the floor won.", "Experienced the squeeze of a lifetime.", "Learned that sometimes the world weighs you down." }, AdvancedCauseOfDeath.Drowning => new string[10] { "Drowned to death.", "Took water aerobics too far.", "Learned swimming the hard way.", "Thought they could breathe underwater.", "Got lost in the deep end.", "Discovered the ocean's bottom isn't a fun visit.", "Played mermaid/merman without the tail.", "Went for a swim in cement shoes.", "Underestimated the power of a puddle.", "Had a wet and deadly encounter." }, AdvancedCauseOfDeath.Abandoned => new string[10] { "Abandoned by their coworkers.", "Learned that loneliness can be fatal.", "Found out that being left behind wasn't a game.", "Discovered that solitude can kill.", "Got ghosted by their survival team.", "Realized too late that no man is an island.", "Was the last one at the party... forever.", "Tried to solo a team sport.", "Learned that 'alone time' should be limited.", "Found out the hard way that there's no 'I' in team." }, AdvancedCauseOfDeath.Electrocution => new string[10] { "Electrocuted to death.", "Got a shocking surprise.", "Tried to conduct electricity with their body.", "Discovered that toasters and bathtubs don't mix.", "Learned that power lines aren't for tightrope walking.", "Had an electrifying dance with death.", "Decided to chew on a power cord.", "Found out lightning does strike twice.", "Had a hair-raising experience with high voltage.", "Received a jolt to the heart, and they're to blame." }, AdvancedCauseOfDeath.Kicking => new string[10] { "Kicked to death.", "Got a kick out of life, literally.", "Learned that high-kicks can be deadly.", "Discovered that shoes can pack a punch.", "Faced the wrath of a thousand angry legs.", "Took a boot to the head one too many times.", "Received the ultimate kick-off.", "Realized that being kicked around is more than an expression.", "Became a victim of a lethal leg day.", "Learned the hard way that some kicks are not for sport." }, AdvancedCauseOfDeath.Enemy_Bracken => new string[10] { "Had their neck snapped by a Bracken.", "Stared at a Bracken too long.", "Hugged a Bracken. It didn't hug back.", "Played peek-a-boo with a Bracken. Lost terribly.", "Tried to make a Bracken smile.", "Thought 'Bracken' was just a weird tree.", "Gave a Bracken a stern talking to.", "Brought a knife to a Bracken fight.", "Tried to outstretch a Bracken.", "Found out Brackens aren't vegetarians." }, AdvancedCauseOfDeath.Enemy_EyelessDog => new string[10] { "Got caught using a mechanical keyboard.", "Was eaten by an Eyeless Dog.", "Forgot to 'speak softly' around an Eyeless Dog.", "Wasn't quiet around an Eyeless Dog.", "Played fetch and became the stick.", "Tried to teach an Eyeless Dog new tricks.", "Thought 'Eyeless' meant 'harmless'.", "Learned Eyeless Dogs don't play dead.", "Whistled in the dark. It came running.", "Misjudged the bite of an Eyeless Dog." }, AdvancedCauseOfDeath.Enemy_ForestGiant => new string[10] { "Swallowed whole by a Forest Giant.", "Played hide-and-seek with a Forest Giant.", "Tried to climb a Forest Giant. Fell.", "Was the small spoon to a Forest Giant.", "Went nature walking in tall-tall grass.", "Gave a Forest Giant a flower. Got a tree.", "Thought 'Forest Giant' was a metaphor.", "Got stepped on during a Forest Giant's stroll.", "Tried to outrun a Forest Giant's appetite.", "Learned that Forest Giants don't do handshakes." }, AdvancedCauseOfDeath.Enemy_CircuitBees => new string[10] { "Electro-stung to death by Circuit Bees.", "Thought Circuit Bees made honey. They made pain.", "Tried to swat a Circuit Bee. Bad idea.", "Disturbed a Circuit Beehive. Lived shortly after.", "Took a zap from the bee zap brigade.", "Wore flower-scented cologne near Circuit Bees.", "Learned that Circuit Bees don't do buzz-offs.", "Caught in the crossfire of a Circuit Bee buzzsaw.", "Tried to catch a Circuit Bee. It caught back.", "Discovered the true meaning of 'shock and awe'." }, AdvancedCauseOfDeath.Enemy_GhostGirl => new string[10] { "Died a mysterious death.", "???", "Played hide-and-seek with a Ghost Girl.", "Tried to exorcise a Ghost Girl. Got exercised.", "Became part of a Ghost Girl's haunting routine.", "Misunderstood the concept of a 'spiritual encounter'.", "Thought Ghost Girl was just a regular girl.", "Learned that Ghost Girls don't like small talk.", "Brought a Ouija board to a Ghost Girl fight.", "Received a ghoulish goodbye." }, AdvancedCauseOfDeath.Enemy_EarthLeviathan => new string[10] { "Swallowed whole by an Earth Leviathan.", "Thought 'Earth Leviathan' was an exotic plant.", "Tried to outdig an Earth Leviathan.", "Learned Earth Leviathans don't play fetch.", "Mistook an Earth Leviathan for a hill.", "Got a one-way ticket to the Earth's core.", "Found out that Earth Leviathans don't do piggybacks.", "Tried to ride the Earth Leviathan express.", "Learned that Earth Leviathans aren't herbivores.", "Discovered the Earth Leviathan's insatiable appetite." }, AdvancedCauseOfDeath.Enemy_BaboonHawk => new string[10] { "Was eaten by a Baboon Hawk.", "Was mauled by a Baboon Hawk.", "Mistook a Baboon Hawk for a friendly parrot.", "Tried to outfly a Baboon Hawk.", "Learned that Baboon Hawks don't do tricks.", "Got a peck on the cheek, Baboon Hawk style.", "Thought a Baboon Hawk was a new yoga pose.", "Offered a Baboon Hawk a banana. Big mistake.", "Played chicken with a Baboon Hawk. Lost.", "Tried to enter a no-fly zone. Baboon Hawk disagreed." }, AdvancedCauseOfDeath.Enemy_Jester => new string[10] { "Was the butt of the Jester's joke.", "Got pranked by the Jester.", "Got popped like a weasel.", "Laughed to death by a Jester's prank.", "Took a Jester seriously. Fatal error.", "Played cards with a Jester. Dealt a dead hand.", "Tried to outjoke a Jester.", "Became the punchline of a deadly joke.", "Received a deadly pie in the face.", "Thought the Jester was just clowning around." }, AdvancedCauseOfDeath.Enemy_CoilHead => new string[10] { "Got in a staring contest with a Coil Head.", "Lost a staring contest with a Coil Head.", "Tried to coil up with a Coil Head.", "Learned that Coil Heads have a tight grip.", "Thought a Coil Head was just misunderstood.", "Tried to untangle a Coil Head's thoughts.", "Played 'Simon Says' with a Coil Head.", "Got wrapped up in a Coil Head's embrace.", "Stared into the abyss, Coil Head stared back.", "Tried to headbutt a Coil Head." }, AdvancedCauseOfDeath.Enemy_SnareFlea => new string[10] { "Was suffocated by a Snare Flea.", "Got caught by a Snare Flea's hug.", "Learned that Snare Fleas aren't cuddly.", "Tried to outjump a Snare Flea.", "Flea circus audition turned deadly.", "Found out Snare Fleas don't play fetch.", "Discovered the Snare Flea's sticky situation.", "Thought they could squash a Snare Flea.", "Played leapfrog with a Snare Flea.", "Learned that Snare Fleas have a tight grip." }, AdvancedCauseOfDeath.Enemy_Hygrodere => new string[10] { "Was absorbed by a Hygrodere.", "Got lost in the sauce.", "Tried to moisturize with a Hygrodere.", "Went for a dip in a Hygrodere pond.", "Got a little too absorbed in nature.", "Learned that Hygroderes aren't for hydration.", "Mistook a Hygrodere for a waterbed.", "Tried to bottle a Hygrodere's essence.", "Learned that Hygroderes don't do splash fights.", "Faced the Hygrodere's engulfing embrace." }, AdvancedCauseOfDeath.Enemy_HoarderBug => new string[10] { "Was hoarded by a Hoarder Bug.", "Became part of a Hoarder Bug's collection.", "Learned that Hoarder Bugs don't share.", "Tried to declutter a Hoarder Bug's nest.", "Mistook a Hoarder Bug for a treasure chest.", "Got a little too possessive with a Hoarder Bug.", "Learned that Hoarder Bugs don't do trades.", "Found out that Hoarder Bugs are avid collectors.", "Thought Hoarder Bugs were just big fans.", "Discovered the Hoarder Bug's greedy grasp." }, AdvancedCauseOfDeath.Enemy_SporeLizard => new string[10] { "Was puffed by a Spore Lizard.", "Inhaled more than just fresh air.", "Thought Spore Lizard spores were perfume.", "Learned that Spore Lizards don't do aromatherapy.", "Tried to catch spores with their tongue.", "Discovered the Spore Lizard's deadly dandruff.", "Thought spores were just fancy confetti.", "Tried to domesticate a Spore Lizard.", "Learned that Spore Lizards are bad for allergies.", "Mistook a Spore Lizard for a mushroom." }, AdvancedCauseOfDeath.Enemy_BunkerSpider => new string[10] { "Ensnared in the Bunker Spider's web.", "Got caught in a web of lies... and death.", "Learned that Bunker Spiders don't do piggybacks.", "Tried to outweb a Bunker Spider.", "Thought web design was easy.", "Discovered the Bunker Spider's sticky situation.", "Played peek-a-boo with a Bunker Spider.", "Mistook a Bunker Spider for a cuddly pet.", "Learned that Bunker Spider silk isn't for knitting.", "Got tangled in a deadly game of cat's cradle." }, AdvancedCauseOfDeath.Enemy_Thumper => new string[10] { "Was ravaged by a Thumper.", "Got thumped by a Thumper.", "Learned that Thumpers don't play drums.", "Tried to thump a Thumper.", "Thought 'Thumper' was a dance move.", "Played patty-cake with a Thumper.", "Discovered the Thumper's seismic activity.", "Mistook a Thumper for a friendly bunny.", "Learned that Thumpers don't do high-fives.", "Felt the Thumper's ground-shaking greeting." }, AdvancedCauseOfDeath.Enemy_MaskedPlayer_Wear => new string[10] { "Nobody cared who they were until they put on the Mask.", "Donned the Mask.", "Learned the Mask comes with strings attached.", "Found out the Mask wasn't just for show.", "Wore the Mask, couldn't handle the role.", "Discovered the Mask's fatal charm.", "Tried to live a double life with the Mask.", "Put on the Mask and exited stage left forever.", "The Mask brought the curtains down on them.", "The Mask's embrace was a tad too tight." }, AdvancedCauseOfDeath.Enemy_MaskedPlayer_Victim => new string[10] { "Became a tragedy at the hands of the Mask.", "Was killed by a Masked coworker.", "Caught in the Mask's lethal performance.", "Fell victim to the Mask's deadly allure.", "Crossed paths with the Mask, and it was curtains.", "Unmasked the Mask's deadly secret.", "Learned that the Mask doesn't play favorites.", "Was the final act in the Mask's play.", "Tried to unmask a killer. It didn't go well.", "Found out the Mask was no mere prop." }, AdvancedCauseOfDeath.Enemy_Nutcracker_Kicked => new string[10] { "Got their nuts cracked by a Nutcracker.", "Was kicked to death by a Nutcracker.", "Learned that Nutcrackers have a mean kick.", "Got a Nutcracker's footloose finale.", "Discovered that Nutcrackers don't dance ballet.", "Played soccer with a Nutcracker. Scored an own goal.", "Thought Nutcrackers only cracked nuts. Was wrong.", "Received the Nutcracker's signature move.", "Had a cracking good time, in the worst way.", "Tested the Nutcracker's kick. It passed." }, AdvancedCauseOfDeath.Enemy_Nutcracker_Shot => new string[10] { "Was at the wrong end of a 21-gun salute.", "Got shot by a Nutcracker.", "Learned that Nutcrackers are sharpshooters.", "Caught a Nutcracker's bullet with their teeth.", "Faced the Nutcracker's firing squad.", "Discovered that Nutcrackers have perfect aim.", "Got a front-row seat to the Nutcracker's gun show.", "Tried to dodge a Nutcracker's bullet. Tried.", "Learned that Nutcrackers don't shoot blanks.", "Was the target of the Nutcracker's wrath." }, AdvancedCauseOfDeath.Player_Jetpack_Gravity => new string[10] { "Flew too close to the sun.", "Ran out of fuel.", "Misjudged their jetpack's altitude limit.", "Tried to touch the sky, kissed the ground instead.", "Found out that what goes up doesn't always come down gently.", "Learned that jetpacks and gravity don't mix.", "Took a nosedive into the law of gravity.", "Ignored their jetpack's low fuel warning.", "Tried to outfly gravity. Gravity won.", "Jetpacked straight into an unexpected landing." }, AdvancedCauseOfDeath.Player_Jetpack_Blast => new string[10] { "Turned into a firework.", "Got blown up by bad piloting.", "Flew high, then went out with a bang.", "Learned that jetpacks can be volatile.", "Took a jetpack joyride to a fiery end.", "Ignited a jetpack-fueled explosion.", "Had a blast-off that turned into a blast.", "Learned to fly, then learned to explode.", "Thought jetpack flame was just for show.", "Missed the jetpack's user manual page on explosions." }, AdvancedCauseOfDeath.Player_Murder_Melee => new string[10] { "Was the victim of a murder.", "Got murdered.", "Was bludgeoned to death by a coworker.", "Felt the final hit of workplace violence.", "Discovered the deadly side of office politics.", "Learned that some coworkers are cutthroat, literally.", "Was on the receiving end of a killer punchline.", "Found out that the pen can be mightier than the sword.", "Took team building exercises to a fatal level.", "Learned that 'backstabber' is sometimes literal." }, AdvancedCauseOfDeath.Player_Murder_Shotgun => new string[10] { "Was the victim of a murder.", "Got murdered.", "Was shot to death by a coworker.", "Learned that shotguns are not for conflict resolution.", "Was at the business end of office politics.", "Discovered that some meetings are final.", "Faced the ultimate 'you're fired' scenario.", "Found out the conference room was a kill zone.", "Took a shotgun shell seminar.", "Received a lethal lesson in shotgun diplomacy." }, AdvancedCauseOfDeath.Player_Quicksand => new string[10] { "Got stuck in quicksand.", "Drowned in quicksand", "Couldn't outpace the quicksand.", "Found out that quicksand isn't a spa treatment.", "Played in the sand, stayed forever.", "Mistook quicksand for a mud bath.", "Learned that quicksand plays for keeps.", "Took a quicksand pit stop, permanently.", "Tried to quickstep over quicksand.", "Discovered that quicksand doesn't come with an escape key." }, AdvancedCauseOfDeath.Player_StunGrenade => new string[10] { "Was the victim of a murder.", "Got a shocking end from a stun grenade.", "Learned that stun grenades can be stunningly lethal.", "Was shocked into the hereafter.", "Had a stunningly brief encounter with a grenade.", "Discovered the electrifying truth about stun grenades.", "Was left stunned... forever.", "Got a hair-raising, life-ending jolt.", "Found out that some shocks are final.", "Received a stunning exit cue." }, AdvancedCauseOfDeath.Other_DepositItemsDesk => new string[10] { "Received a demotion.", "Was put on disciplinary leave.", "Forgot their employee ID and couldn't get their items.", "Tried to deposit a live grenade.", "Mistakenly deposited their pet hamster instead of their items.", "Got into a fight with the Deposit Items Desk attendant.", "Tripped and fell into the Deposit Items Desk conveyor belt.", "Was eaten by a Grue while waiting in line.", "Discovered that their items were already deposited in their inventory.", "Realized that they didn't actually have any items to deposit." }, AdvancedCauseOfDeath.Other_Dropship => new string[10] { "Was crushed by the Item Dropship.", "Couldn't wait for their items and tried to catch the Dropship.", "Got too impatient for their items and shot down the Dropship.", "Was using the Dropship as a personal trampoline.", "Tried to ride the Dropship like a surfboard.", "Challenged the Dropship to a game of chicken.", "Forgot to get out of the way of the Dropship.", "Was distracted by a butterfly and walked into the Dropship's path.", "Was sleepwalking and wandered into the Dropship's landing zone.", "Was trying to steal the Dropship and sell it on the black market." }, AdvancedCauseOfDeath.Other_Landmine => new string[10] { "Stepped on a landmine.", "Mistook a landmine for a lost contact lens.", "Thought a landmine was a new type of mushroom and tried to eat it.", "Was using a landmine as a doorstop.", "Tried to defuse a landmine with a screwdriver.", "Kicked a landmine like a soccer ball.", "Was dancing on a landmine and forgot to stop.", "Was sleepwalking and stepped on a landmine.", "Was trying to collect landmines to build a fort.", "Was using a landmine as a paperweight." }, AdvancedCauseOfDeath.Other_Turret => new string[10] { "Got shot by a turret.", "Challenged a turret to a staring contest and lost.", "Tried to pet a turret.", "Thought a turret was a new type of vending machine.", "Was using a turret as a hat rack.", "Tried to dance with a turret.", "Was sleepwalking and walked into a turret's line of fire.", "Was trying to steal a turret and sell it on the black market.", "Was using a turret as a target for archery practice.", "Was trying to communicate with a turret using Morse code." }, AdvancedCauseOfDeath.Other_Lightning => new string[10] { "Was struck by lightning.", "Was flying a kite in a thunderstorm.", "Was taking a bath during a lightning storm.", "Was holding a metal rod during a lightning storm.", "Was standing under a tree during a lightning storm.", "Was wearing a tinfoil hat during a lightning storm.", "Was trying to catch lightning in a bottle.", "Was using a lightning rod as a selfie stick.", "Was trying to summon Thor with a homemade lightning rod.", "Was dancing on a hilltop during a lightning storm." }, _ => new string[10] { "Most sincerely dead.", "Died somehow.", "Passed away under mysterious circumstances.", "Left this world in an unspecified manner.", "Ceased living in an indeterminate fashion.", "Reached an uncertain end.", "Met their demise through unknown means.", "Expired due to reasons yet to be determined.", "Shuffled off this mortal coil in a vague way.", "Concluded their life's story with an enigmatic ellipsis." }, }; } internal static void SetCauseOfDeath(PlayerControllerB playerControllerB, object enemy_BaboonHawk) { throw new NotImplementedException(); } } internal enum AdvancedCauseOfDeath { Unknown, Bludgeoning, Gravity, Blast, Strangulation, Suffocation, Mauling, Gunshots, Crushing, Drowning, Abandoned, Electrocution, Kicking, Enemy_BaboonHawk, Enemy_Bracken, Enemy_CircuitBees, Enemy_CoilHead, Enemy_EarthLeviathan, Enemy_EyelessDog, Enemy_ForestGiant, Enemy_GhostGirl, Enemy_Hygrodere, Enemy_Jester, Enemy_SnareFlea, Enemy_SporeLizard, Enemy_HoarderBug, Enemy_Thumper, Enemy_BunkerSpider, Enemy_MaskedPlayer_Wear, Enemy_MaskedPlayer_Victim, Enemy_Nutcracker_Kicked, Enemy_Nutcracker_Shot, Player_Jetpack_Gravity, Player_Jetpack_Blast, Player_Quicksand, Player_Murder_Melee, Player_Murder_Shotgun, Player_StunGrenade, Other_Landmine, Other_Turret, Other_Lightning, Other_DepositItemsDesk, Other_Dropship } internal class DeathBroadcaster { private const string SIGNATURE_DEATH = "com.anythinggoesgit.moredeathnotes.death"; public static void Initialize() { if (Plugin.Instance.IsLCAPIPresent) { DeathBroadcasterLCAPI.Initialize(); } else { Plugin.Instance.PluginLogger.LogInfo((object)"LC_API is not present! Skipping registration..."); } } public static void BroadcastCauseOfDeath(int playerId, AdvancedCauseOfDeath causeOfDeath) { AttemptBroadcast(BuildDataCauseOfDeath(playerId, causeOfDeath), "com.anythinggoesgit.moredeathnotes.death"); } private static string BuildDataCauseOfDeath(int playerId, AdvancedCauseOfDeath causeOfDeath) { string text = playerId.ToString(); int num = (int)causeOfDeath; return text + "|" + num; } private static void AttemptBroadcast(string data, string signature) { if (Plugin.Instance.IsLCAPIPresent) { DeathBroadcasterLCAPI.AttemptBroadcast(data, signature); } else { Plugin.Instance.PluginLogger.LogInfo((object)"LC_API is not present! Skipping broadcast..."); } } } public static class PluginInfo { public const string PLUGIN_ID = "MoreDeathNotes"; public const string PLUGIN_NAME = "MoreDeathNotes"; public const string PLUGIN_VERSION = "1.4.0"; public const string PLUGIN_GUID = "com.anythinggoesgit.moredeathnotes"; } [BepInPlugin("com.anythinggoesgit.moredeathnotes", "MoreDeathNotes", "1.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static readonly Random RANDOM = new Random(); public ManualLogSource PluginLogger; public PluginConfig PluginConfig; public bool IsLCAPIPresent; public static Plugin Instance { get; private set; } private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) Instance = this; PluginLogger = ((BaseUnityPlugin)this).Logger; new Harmony("com.anythinggoesgit.moredeathnotes").PatchAll(); PluginLogger.LogInfo((object)"Plugin MoreDeathNotes (com.anythinggoesgit.moredeathnotes) is loaded!"); LoadConfig(); QueryLCAPI(); DeathBroadcaster.Initialize(); } private void QueryLCAPI() { PluginLogger.LogInfo((object)"Checking for LC_API..."); if (Chainloader.PluginInfos.ContainsKey("LC_API")) { Chainloader.PluginInfos.TryGetValue("LC_API", out var value); if (value == null) { PluginLogger.LogError((object)"Detected LC_API, but could not get plugin info!"); IsLCAPIPresent = false; } else { PluginLogger.LogInfo((object)("LCAPI is present! " + value.Metadata.GUID + ":" + value.Metadata.Version)); IsLCAPIPresent = true; } } else { PluginLogger.LogInfo((object)"LCAPI is not present."); IsLCAPIPresent = false; } } private void LoadConfig() { PluginConfig = new PluginConfig(); PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); } } public class PluginConfig { private ConfigEntry<bool> DisplayCauseOfDeath; private ConfigEntry<bool> SeriousDeathMessages; private ConfigEntry<bool> DisplayFunnyNotes; private ConfigEntry<bool> DeathReplacesNotes; public void BindConfig(ConfigFile _config) { DisplayCauseOfDeath = _config.Bind<bool>("General", "DisplayCauseOfDeath", true, "Display the cause of death in the player notes."); SeriousDeathMessages = _config.Bind<bool>("General", "SeriousDeathMessages", false, "Cause of death messages are more to-the-point."); DisplayFunnyNotes = _config.Bind<bool>("General", "DisplayFunnyNotes", true, "Display a random note when the player has no notes."); DeathReplacesNotes = _config.Bind<bool>("General", "DeathReplacesNotes", true, "True to replace notes when the player dies, false to append."); } public bool ShouldDisplayCauseOfDeath() { return DisplayCauseOfDeath.Value; } public bool ShouldUseSeriousDeathMessages() { return SeriousDeathMessages.Value; } public bool ShouldDisplayFunnyNotes() { return DisplayFunnyNotes.Value; } public bool ShouldDeathReplaceNotes() { return DeathReplacesNotes.Value; } } } namespace Coroner.Patch { [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyPatch("KillPlayer")] internal class PlayerControllerBKillPlayerPatch { public static void Prefix(PlayerControllerB __instance, ref CauseOfDeath causeOfDeath) { try { if ((int)causeOfDeath == 300) { Plugin.Instance.PluginLogger.LogDebug((object)"Player died from item dropship! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Other_Dropship); causeOfDeath = (CauseOfDeath)8; } else if (__instance.isSinking && (int)causeOfDeath == 5) { Plugin.Instance.PluginLogger.LogDebug((object)"Player died of suffociation while sinking in quicksand! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Player_Quicksand); } else if ((int)causeOfDeath != 3) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is dying! No cause of death registered in hook..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in PlayerControllerBKillPlayerPatch.Prefix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(DepositItemsDesk))] [HarmonyPatch("AnimationGrabPlayer")] internal class DepositItemsDeskAnimationGrabPlayerPatch { public static void Postfix(int playerID) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after tentacle devouring..."); PlayerControllerB playerController = StartOfRound.Instance.allPlayerScripts[playerID]; Plugin.Instance.PluginLogger.LogDebug((object)"Player is dying! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(playerController, AdvancedCauseOfDeath.Other_DepositItemsDesk); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in DepositItemsDeskAnimationGrabPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(JesterAI))] [HarmonyPatch("killPlayerAnimation")] internal class JesterAIKillPlayerAnimationPatch { public static void Postfix(int playerId) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Jester mauling..."); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(val, AdvancedCauseOfDeath.Enemy_Jester); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in JesterAIKillPlayerAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(SandWormAI))] [HarmonyPatch("EatPlayer")] internal class SandWormAIEatPlayerPatch { public static void Postfix(PlayerControllerB playerScript) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Sand Worm devouring..."); if ((Object)(object)playerScript == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(playerScript, AdvancedCauseOfDeath.Enemy_EarthLeviathan); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in SandWormAIEatPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(RedLocustBees))] [HarmonyPatch("BeeKillPlayerOnLocalClient")] internal class RedLocustBeesBeeKillPlayerOnLocalClientPatch { public static void Postfix(int playerId) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Circuit Bee electrocution..."); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (val.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(val, AdvancedCauseOfDeath.Enemy_CircuitBees); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in RedLocustBeesBeeKillPlayerOnLocalClientPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(DressGirlAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class DressGirlAIOnCollideWithPlayerPatch { public static void Postfix(DressGirlAI __instance) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Processing Ghost Girl player collision..."); if ((Object)(object)__instance.hauntingPlayer == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after collision!"); } else if (__instance.hauntingPlayer.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance.hauntingPlayer, AdvancedCauseOfDeath.Enemy_GhostGirl); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in DressGirlAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(FlowermanAI))] [HarmonyPatch("killAnimation")] internal class FlowermanAIKillAnimationPatch { public static void Postfix(FlowermanAI __instance) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Bracken snapping neck..."); if ((Object)(object)((EnemyAI)__instance).inSpecialAnimationWithPlayer == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after snapping neck!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(((EnemyAI)__instance).inSpecialAnimationWithPlayer, AdvancedCauseOfDeath.Enemy_Bracken); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in FlowermanAIKillAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(ForestGiantAI))] [HarmonyPatch("EatPlayerAnimation")] internal class ForestGiantAIEatPlayerAnimationPatch { public static void Postfix(PlayerControllerB playerBeingEaten) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after Forest Giant devouring..."); if ((Object)(object)playerBeingEaten == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(playerBeingEaten, AdvancedCauseOfDeath.Enemy_ForestGiant); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in ForestGiantAIEatPlayerAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(MouthDogAI))] [HarmonyPatch("KillPlayer")] internal class MouthDogAIKillPlayerPatch { public static void Postfix(int playerId) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Accessing state after dog devouring..."); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(val, AdvancedCauseOfDeath.Enemy_EyelessDog); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in MouthDogAIKillPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(CentipedeAI))] [HarmonyPatch("DamagePlayerOnIntervals")] internal class CentipedeAIDamagePlayerOnIntervalsPatch { public static void Postfix(CentipedeAI __instance) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Snare Flea damage..."); if ((Object)(object)__instance.clingingToPlayer == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player being clung to!"); } else if (__instance.clingingToPlayer.isPlayerDead && (int)__instance.clingingToPlayer.causeOfDeath == 5) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance.clingingToPlayer, AdvancedCauseOfDeath.Enemy_SnareFlea); } else if (__instance.clingingToPlayer.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player somehow died while attacked by Snare Flea! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in CentipedeAIDamagePlayerOnIntervalsPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(BaboonBirdAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class BaboonBirdAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Baboon Hawk damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_BaboonHawk); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in BaboonBirdAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(PlayerControllerB))] [HarmonyPatch("DamagePlayerFromOtherClientClientRpc")] internal class PlayerControllerBDamagePlayerFromOtherClientClientRpcPatch { public static void Postfix(PlayerControllerB __instance) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling friendly fire damage..."); if ((Object)(object)__instance == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access victim after death!"); } else if (__instance.isPlayerDead) { if ((int)__instance.causeOfDeath == 1) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Player_Murder_Melee); } else if ((int)__instance.causeOfDeath == 6) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Player_Murder_Melee); } else if ((int)__instance.causeOfDeath == 7) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(__instance, AdvancedCauseOfDeath.Player_Murder_Shotgun); } else { Plugin.Instance.PluginLogger.LogWarning((object)("Player was killed by someone else but we don't know how! " + ((object)(CauseOfDeath)(ref __instance.causeOfDeath)).ToString())); } } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in PlayerControllerBDamagePlayerFromOtherClientClientRpcPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(PufferAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class PufferAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Spore Lizard damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_SporeLizard); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in PufferAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(SpringManAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class SpringManAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Coil Head damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_CoilHead); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in SpringManAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(BlobAI))] [HarmonyPatch("SlimeKillPlayerEffectServerRpc")] internal class BlobAISlimeKillPlayerEffectServerRpcPatch { public static void Postfix(int playerKilled) { try { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerKilled]; if ((Object)(object)val == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (val.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(val, AdvancedCauseOfDeath.Enemy_Hygrodere); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in BlobAISlimeKillPlayerEffectServerRpcPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(HoarderBugAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class HoarderBugAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Hoarder Bug damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_HoarderBug); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in HoarderBugAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(CrawlerAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class CrawlerAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Thumper damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_Thumper); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in CrawlerAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(SandSpiderAI))] [HarmonyPatch("OnCollideWithPlayer")] internal class SandSpiderAIOnCollideWithPlayerPatch { public static void Postfix(Collider other) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling Bunker Spider damage..."); PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (component.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(component, AdvancedCauseOfDeath.Enemy_BunkerSpider); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in SandSpiderAIOnCollideWithPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(NutcrackerEnemyAI))] [HarmonyPatch("LegKickPlayer")] internal class NutcrackerEnemyAILegKickPlayerPatch { public static void Postfix(int playerId) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Nutcracker kicked a player to death!"); PlayerControllerB playerController = StartOfRound.Instance.allPlayerScripts[playerId]; Plugin.Instance.PluginLogger.LogDebug((object)"Player is dying! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(playerController, AdvancedCauseOfDeath.Enemy_Nutcracker_Kicked); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in NutcrackerEnemyAILegKickPlayerPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(ShotgunItem))] [HarmonyPatch("ShootGun")] internal class ShotgunItemShootGunPatch { public static void Postfix(ShotgunItem __instance) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 try { Plugin.Instance.PluginLogger.LogDebug((object)"Handling shotgun shot..."); PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access local player after shotgun shot!"); } else if (localPlayerController.isPlayerDead && (int)localPlayerController.causeOfDeath == 7) { if (((GrabbableObject)__instance).isHeldByEnemy) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(localPlayerController, AdvancedCauseOfDeath.Enemy_Nutcracker_Shot); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(localPlayerController, AdvancedCauseOfDeath.Player_Murder_Shotgun); } } else if (localPlayerController.isPlayerDead) { Plugin.Instance.PluginLogger.LogWarning((object)("Player died while attacked by shotgun? Skipping... " + ((object)(CauseOfDeath)(ref localPlayerController.causeOfDeath)).ToString())); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in ShotgunItemShootGunPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(MaskedPlayerEnemy))] [HarmonyPatch("killAnimation")] internal class MaskedPlayerEnemykillAnimationPatch { public static void Postfix(MaskedPlayerEnemy __instance) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Masked Player killed someone..."); PlayerControllerB inSpecialAnimationWithPlayer = ((EnemyAI)__instance).inSpecialAnimationWithPlayer; if ((Object)(object)inSpecialAnimationWithPlayer == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); return; } Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(inSpecialAnimationWithPlayer, AdvancedCauseOfDeath.Enemy_MaskedPlayer_Victim); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in MaskedPlayerEnemykillAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(HauntedMaskItem))] [HarmonyPatch("FinishAttaching")] internal class HauntedMaskItemFinishAttachingPatch { public static void Postfix(HauntedMaskItem __instance) { try { Plugin.Instance.PluginLogger.LogDebug((object)"Masked Player killed someone..."); PlayerControllerB value = Traverse.Create((object)__instance).Field("previousPlayerHeldBy").GetValue<PlayerControllerB>(); if ((Object)(object)value == (Object)null) { Plugin.Instance.PluginLogger.LogWarning((object)"Could not access player after death!"); } else if (value.isPlayerDead) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(value, AdvancedCauseOfDeath.Enemy_MaskedPlayer_Wear); } else { Plugin.Instance.PluginLogger.LogDebug((object)"Player is somehow still alive! Skipping..."); } } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in HauntedMaskItemFinishAttachingPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(ExtensionLadderItem))] [HarmonyPatch("StartLadderAnimation")] internal class ExtensionLadderItemStartLadderAnimationPatch { public static void Postfix(ExtensionLadderItem __instance) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) try { Plugin.Instance.PluginLogger.LogDebug((object)"Extension ladder started animation! Modifying kill trigger..."); GameObject gameObject = ((Component)__instance).gameObject; if ((Object)(object)gameObject == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch GameObject from ExtensionLadderItem."); } Transform obj = gameObject.transform.Find("AnimContainer/MeshContainer/LadderMeshContainer/BaseLadder/LadderSecondPart/KillTrigger"); if ((Object)(object)obj == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillTrigger Transform from ExtensionLadderItem."); } GameObject gameObject2 = ((Component)obj).gameObject; if ((Object)(object)gameObject2 == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillTrigger GameObject from ExtensionLadderItem."); } KillLocalPlayer component = gameObject2.GetComponent<KillLocalPlayer>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillLocalPlayer from KillTrigger GameObject."); } component.causeOfDeath = (CauseOfDeath)8; } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in ExtensionLadderItemStartLadderAnimationPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(ItemDropship))] [HarmonyPatch("Start")] internal class ItemDropshipStartPatch { public static void Postfix(ItemDropship __instance) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) try { Plugin.Instance.PluginLogger.LogDebug((object)"Item dropship spawned! Modifying kill trigger..."); GameObject gameObject = ((Component)__instance).gameObject; if ((Object)(object)gameObject == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch GameObject from ItemDropship."); } Transform obj = gameObject.transform.Find("ItemShip/KillTrigger"); if ((Object)(object)obj == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillTrigger Transform from ItemDropship."); } GameObject gameObject2 = ((Component)obj).gameObject; if ((Object)(object)gameObject2 == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillTrigger GameObject from ItemDropship."); } KillLocalPlayer component = gameObject2.GetComponent<KillLocalPlayer>(); if ((Object)(object)component == (Object)null) { Plugin.Instance.PluginLogger.LogError((object)"Could not fetch KillLocalPlayer from KillTrigger GameObject."); } component.causeOfDeath = (CauseOfDeath)300; } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in ItemDropshipStartPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } } [HarmonyPatch(typeof(Turret))] [HarmonyPatch("Update")] public class TurretUpdatePatch { public static void Postfix(Turret __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if ((int)__instance.turretMode == 2) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (localPlayerController.isPlayerDead && (int)localPlayerController.causeOfDeath == 7) { Plugin.Instance.PluginLogger.LogDebug((object)"Player is now dead! Setting special cause of death..."); AdvancedDeathTracker.SetCauseOfDeath(localPlayerController, AdvancedCauseOfDeath.Other_Turret); } } } } [HarmonyPatch(typeof(Landmine))] [HarmonyPatch("SpawnExplosion")] public class LandmineSpawnExplosionPatch { private const string KILL_PLAYER_SIGNATURE = "Void KillPlayer(UnityEngine.Vector3, Boolean, CauseOfDeath, Int32)"; private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase method) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<CodeInstruction> list2 = BuildInstructionsToInsert(method); if (list2 == null) { Plugin.Instance.PluginLogger.LogError((object)"Could not build instructions to insert in LandmineSpawnExplosionPatch! Safely aborting..."); return instructions; } int num = -1; for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (val.opcode == OpCodes.Callvirt && val.operand.ToString() == "Void KillPlayer(UnityEngine.Vector3, Boolean, CauseOfDeath, Int32)") { num = i; break; } } if (num == -1) { Plugin.Instance.PluginLogger.LogError((object)"Could not find PlayerControllerB.KillPlayer call in LandmineSpawnExplosionPatch! Safely aborting..."); return instructions; } Plugin.Instance.PluginLogger.LogInfo((object)"Injecting patch into Landmine.SpawnExplosion..."); list.InsertRange(num, list2); Plugin.Instance.PluginLogger.LogInfo((object)"Done."); return list; } private static List<CodeInstruction> BuildInstructionsToInsert(MethodBase method) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); int num = 2; IList<LocalVariableInfo> localVariables = method.GetMethodBody().LocalVariables; LocalVariableInfo localVariableInfo = null; for (int i = 0; i < localVariables.Count; i++) { LocalVariableInfo localVariableInfo2 = localVariables[i]; if (localVariableInfo2.LocalType == typeof(PlayerControllerB)) { if (localVariableInfo != null) { Plugin.Instance.PluginLogger.LogError((object)"Found multiple PlayerControllerB local variables in LandmineSpawnExplosionPatch!"); return null; } localVariableInfo = localVariableInfo2; break; } } list.Add(new CodeInstruction(OpCodes.Ldloc_S, (object)localVariableInfo.LocalIndex)); list.Add(new CodeInstruction(OpCodes.Ldarg, (object)num)); list.Add(new CodeInstruction(OpCodes.Call, (object)typeof(LandmineSpawnExplosionPatch).GetMethod("RewriteCauseOfDeath"))); return list; } public static void RewriteCauseOfDeath(PlayerControllerB targetPlayer, float killRange) { AdvancedCauseOfDeath causeOfDeath = AdvancedCauseOfDeath.Blast; if (killRange == 5f) { causeOfDeath = AdvancedCauseOfDeath.Player_Jetpack_Blast; } else if (killRange == 5.7f) { causeOfDeath = AdvancedCauseOfDeath.Other_Landmine; } else if (killRange == 2.4f) { causeOfDeath = AdvancedCauseOfDeath.Other_Lightning; } AdvancedDeathTracker.SetCauseOfDeath(targetPlayer, causeOfDeath); } } [HarmonyPatch(typeof(HUDManager))] [HarmonyPatch("FillEndGameStats")] internal class HUDManagerFillEndGameStatsPatch { public static void Postfix(HUDManager __instance) { try { OverridePerformanceReport(__instance); } catch (Exception ex) { Plugin.Instance.PluginLogger.LogError((object)("Error in HUDManagerFillEndGameStatsPatch.Postfix: " + ex)); Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace); } } private static Random BuildSyncedRandom(HUDManager __instance) { int randomMapSeed = StartOfRound.Instance.randomMapSeed; Plugin.Instance.PluginLogger.LogDebug((object)("Syncing randomization to map seed: '" + randomMapSeed + "'")); return new Random(randomMapSeed); } private static void OverridePerformanceReport(HUDManager __instance) { Plugin.Instance.PluginLogger.LogDebug((object)"Applying Coroner patches to player notes..."); Random random = BuildSyncedRandom(__instance); for (int i = 0; i < __instance.statsUIElements.playerNotesText.Length; i++) { PlayerControllerB val = __instance.playersManager.allPlayerScripts[i]; if (!val.disconnectedMidGame && !val.isPlayerDead && !val.isPlayerControlled) { Plugin.Instance.PluginLogger.LogInfo((object)("Player " + i + " is not controlled by a player. Skipping...")); continue; } TextMeshProUGUI val2 = __instance.statsUIElements.playerNotesText[i]; if (val.isPlayerDead) { if (Plugin.Instance.PluginConfig.ShouldDisplayCauseOfDeath()) { if (Plugin.Instance.PluginConfig.ShouldDeathReplaceNotes()) { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " is dead! Replacing notes with Cause of Death...")); ((TMP_Text)val2).text = "Cause of Death: \n"; } else { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " is dead! Appending notes with Cause of Death...")); } AdvancedCauseOfDeath causeOfDeath = AdvancedDeathTracker.GetCauseOfDeath(val); string text = "* " + AdvancedDeathTracker.StringifyCauseOfDeath(causeOfDeath, random) + "\n"; ((TMP_Text)val2).text = ((TMP_Text)val2).text + text; } else { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " is dead, but Config says leave it be...")); } } else if (Plugin.Instance.PluginConfig.ShouldDisplayFunnyNotes()) { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " has no notes! Injecting something funny...")); string text2 = "* " + AdvancedDeathTracker.StringifyCauseOfDeath(null, random) + "\n"; ((TMP_Text)val2).text = ((TMP_Text)val2).text + text2; ((TMP_Text)val2).text = "Notes: \n"; ((TMP_Text)val2).text = ((TMP_Text)val2).text + text2; } else { Plugin.Instance.PluginLogger.LogInfo((object)("[REPORT] Player " + i + " has no notes, but Config says leave it be...")); } } AdvancedDeathTracker.ClearDeathTracker(); } } } namespace Coroner.LCAPI { internal class DeathBroadcasterLCAPI { private const string SIGNATURE_DEATH = "com.anythinggoesgit.moredeathnotes.death"; public static void Initialize() { Plugin.Instance.PluginLogger.LogDebug((object)"Initializing DeathBroadcaster..."); if (Plugin.Instance.IsLCAPIPresent) { Plugin.Instance.PluginLogger.LogDebug((object)"LC_API is present! Registering signature..."); Networking.GetString = (Action<string, string>)Delegate.Combine(Networking.GetString, new Action<string, string>(OnBroadcastString)); } else { Plugin.Instance.PluginLogger.LogError((object)"LC_API is not present! Why did you try to register the DeathBroadcaster?"); } } private static void OnBroadcastString(string data, string signature) { if (signature == "com.anythinggoesgit.moredeathnotes.death") { Plugin.Instance.PluginLogger.LogDebug((object)"Broadcast has been received from LC_API!"); string[] array = data.Split('|'); int playerIndex = int.Parse(array[0]); AdvancedCauseOfDeath advancedCauseOfDeath = (AdvancedCauseOfDeath)int.Parse(array[1]); Plugin.Instance.PluginLogger.LogDebug((object)("Player " + playerIndex + " died of " + AdvancedDeathTracker.StringifyCauseOfDeath((AdvancedCauseOfDeath?)advancedCauseOfDeath))); AdvancedDeathTracker.SetCauseOfDeath(playerIndex, advancedCauseOfDeath, broadcast: false); } } public static void AttemptBroadcast(string data, string signature) { if (Plugin.Instance.IsLCAPIPresent) { Plugin.Instance.PluginLogger.LogDebug((object)"LC_API is present! Broadcasting..."); Networking.Broadcast(data, signature); } else { Plugin.Instance.PluginLogger.LogDebug((object)"LC_API is not present! Skipping broadcast..."); } } } }
plugins/MoreSuits.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("MoreSuits")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A mod that adds more suit options to Lethal Company")] [assembly: AssemblyFileVersion("1.4.1.0")] [assembly: AssemblyInformationalVersion("1.4.1")] [assembly: AssemblyProduct("MoreSuits")] [assembly: AssemblyTitle("MoreSuits")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.1.0")] [module: UnverifiableCode] namespace MoreSuits; [BepInPlugin("x753.More_Suits", "More Suits", "1.4.1")] public class MoreSuitsMod : BaseUnityPlugin { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPatch(ref StartOfRound __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Expected O, but got Unknown //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown try { if (SuitsAdded) { return; } int count = __instance.unlockablesList.unlockables.Count; UnlockableItem val = new UnlockableItem(); int num = 0; for (int i = 0; i < __instance.unlockablesList.unlockables.Count; i++) { UnlockableItem val2 = __instance.unlockablesList.unlockables[i]; if (!((Object)(object)val2.suitMaterial != (Object)null) || !val2.alreadyUnlocked) { continue; } val = val2; List<string> list = Directory.GetDirectories(Paths.PluginPath, "moresuits", SearchOption.AllDirectories).ToList(); List<string> list2 = new List<string>(); List<string> list3 = new List<string>(); List<string> list4 = DisabledSuits.ToLower().Replace(".png", "").Split(',') .ToList(); List<string> list5 = new List<string>(); if (!LoadAllSuits) { foreach (string item2 in list) { if (File.Exists(Path.Combine(item2, "!less-suits.txt"))) { string[] collection = new string[9] { "glow", "kirby", "knuckles", "luigi", "mario", "minion", "skeleton", "slayer", "smile" }; list5.AddRange(collection); break; } } } foreach (string item3 in list) { if (item3 != "") { string[] files = Directory.GetFiles(item3, "*.png"); string[] files2 = Directory.GetFiles(item3, "*.matbundle"); list2.AddRange(files); list3.AddRange(files2); } } list3.Sort(); list2.Sort(); try { foreach (string item4 in list3) { Object[] array = AssetBundle.LoadFromFile(item4).LoadAllAssets(); foreach (Object val3 in array) { if (val3 is Material) { Material item = (Material)val3; customMaterials.Add(item); } } } } catch (Exception ex) { Debug.Log((object)("Something went wrong with More Suits! Could not load materials from asset bundle(s). Error: " + ex)); } foreach (string item5 in list2) { if (list4.Contains(Path.GetFileNameWithoutExtension(item5).ToLower())) { continue; } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (list5.Contains(Path.GetFileNameWithoutExtension(item5).ToLower()) && item5.Contains(directoryName)) { continue; } UnlockableItem val4; Material val5; if (Path.GetFileNameWithoutExtension(item5).ToLower() == "default") { val4 = val; val5 = val4.suitMaterial; } else { val4 = JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson((object)val)); val5 = Object.Instantiate<Material>(val4.suitMaterial); } byte[] array2 = File.ReadAllBytes(item5); Texture2D val6 = new Texture2D(2, 2); ImageConversion.LoadImage(val6, array2); val5.mainTexture = (Texture)(object)val6; val4.unlockableName = Path.GetFileNameWithoutExtension(item5); try { string path = Path.Combine(Path.GetDirectoryName(item5), "advanced", val4.unlockableName + ".json"); if (File.Exists(path)) { string[] array3 = File.ReadAllLines(path); for (int j = 0; j < array3.Length; j++) { string[] array4 = array3[j].Trim().Split(':'); if (array4.Length != 2) { continue; } string text = array4[0].Trim('"', ' ', ','); string text2 = array4[1].Trim('"', ' ', ','); if (text2.Contains(".png")) { byte[] array5 = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(item5), "advanced", text2)); Texture2D val7 = new Texture2D(2, 2); ImageConversion.LoadImage(val7, array5); val5.SetTexture(text, (Texture)(object)val7); continue; } if (text == "PRICE" && int.TryParse(text2, out var result)) { try { val4 = AddToRotatingShop(val4, result, __instance.unlockablesList.unlockables.Count); } catch (Exception ex2) { Debug.Log((object)("Something went wrong with More Suits! Could not add a suit to the rotating shop. Error: " + ex2)); } continue; } switch (text2) { case "KEYWORD": val5.EnableKeyword(text); continue; case "DISABLEKEYWORD": val5.DisableKeyword(text); continue; case "SHADERPASS": val5.SetShaderPassEnabled(text, true); continue; case "DISABLESHADERPASS": val5.SetShaderPassEnabled(text, false); continue; } float result2; Vector4 vector; if (text == "SHADER") { Shader shader = Shader.Find(text2); val5.shader = shader; } else if (text == "MATERIAL") { foreach (Material customMaterial in customMaterials) { if (((Object)customMaterial).name == text2) { val5 = Object.Instantiate<Material>(customMaterial); val5.mainTexture = (Texture)(object)val6; break; } } } else if (float.TryParse(text2, out result2)) { val5.SetFloat(text, result2); } else if (TryParseVector4(text2, out vector)) { val5.SetVector(text, vector); } } } } catch (Exception ex3) { Debug.Log((object)("Something went wrong with More Suits! Error: " + ex3)); } val4.suitMaterial = val5; if (val4.unlockableName.ToLower() != "default") { if (num == MaxSuits) { Debug.Log((object)"Attempted to add a suit, but you've already reached the max number of suits! Modify the config if you want more."); continue; } __instance.unlockablesList.unlockables.Add(val4); num++; } } SuitsAdded = true; break; } UnlockableItem val8 = JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson((object)val)); val8.alreadyUnlocked = false; val8.hasBeenMoved = false; val8.placedPosition = Vector3.zero; val8.placedRotation = Vector3.zero; val8.unlockableType = 753; while (__instance.unlockablesList.unlockables.Count < count + MaxSuits) { __instance.unlockablesList.unlockables.Add(val8); } } catch (Exception ex4) { Debug.Log((object)("Something went wrong with More Suits! Error: " + ex4)); } } [HarmonyPatch("PositionSuitsOnRack")] [HarmonyPrefix] private static bool PositionSuitsOnRackPatch(ref StartOfRound __instance) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) List<UnlockableSuit> source = Object.FindObjectsOfType<UnlockableSuit>().ToList(); source = source.OrderBy((UnlockableSuit suit) => suit.syncedSuitID.Value).ToList(); int num = 0; foreach (UnlockableSuit item in source) { AutoParentToShip component = ((Component)item).gameObject.GetComponent<AutoParentToShip>(); component.overrideOffset = true; float num2 = 0.18f; if (MakeSuitsFitOnRack && source.Count > 13) { num2 /= (float)Math.Min(source.Count, 20) / 12f; } component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + __instance.rightmostSuitPosition.forward * num2 * (float)num; component.rotationOffset = new Vector3(0f, 90f, 0f); num++; } return false; } } private const string modGUID = "x753.More_Suits"; private const string modName = "More Suits"; private const string modVersion = "1.4.1"; private readonly Harmony harmony = new Harmony("x753.More_Suits"); private static MoreSuitsMod Instance; public static bool SuitsAdded = false; public static string DisabledSuits; public static bool LoadAllSuits; public static bool MakeSuitsFitOnRack; public static int MaxSuits; public static List<Material> customMaterials = new List<Material>(); private static TerminalNode cancelPurchase; private static TerminalKeyword buyKeyword; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } DisabledSuits = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Disabled Suit List", "UglySuit751.png,UglySuit752.png,UglySuit753.png", "Comma-separated list of suits that shouldn't be loaded").Value; LoadAllSuits = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Ignore !less-suits.txt", false, "If true, ignores the !less-suits.txt file and will attempt to load every suit, except those in the disabled list. This should be true if you're not worried about having too many suits.").Value; MakeSuitsFitOnRack = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Make Suits Fit on Rack", true, "If true, squishes the suits together so more can fit on the rack.").Value; MaxSuits = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Max Suits", 100, "The maximum number of suits to load. If you have more, some will be ignored.").Value; harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin More Suits is loaded!"); } private static UnlockableItem AddToRotatingShop(UnlockableItem newSuit, int price, int unlockableID) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown Terminal val = Object.FindObjectOfType<Terminal>(); for (int i = 0; i < val.terminalNodes.allKeywords.Length; i++) { if (((Object)val.terminalNodes.allKeywords[i]).name == "Buy") { buyKeyword = val.terminalNodes.allKeywords[i]; break; } } newSuit.alreadyUnlocked = false; newSuit.hasBeenMoved = false; newSuit.placedPosition = Vector3.zero; newSuit.placedRotation = Vector3.zero; newSuit.shopSelectionNode = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)newSuit.shopSelectionNode).name = newSuit.unlockableName + "SuitBuy1"; newSuit.shopSelectionNode.creatureName = newSuit.unlockableName + " suit"; newSuit.shopSelectionNode.displayText = "You have requested to order " + newSuit.unlockableName + " suits.\nTotal cost of item: [totalCost].\n\nPlease CONFIRM or DENY.\n\n"; newSuit.shopSelectionNode.clearPreviousText = true; newSuit.shopSelectionNode.shipUnlockableID = unlockableID; newSuit.shopSelectionNode.itemCost = price; newSuit.shopSelectionNode.overrideOptions = true; CompatibleNoun val2 = new CompatibleNoun(); val2.noun = ScriptableObject.CreateInstance<TerminalKeyword>(); val2.noun.word = "confirm"; val2.noun.isVerb = true; val2.result = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val2.result).name = newSuit.unlockableName + "SuitBuyConfirm"; val2.result.creatureName = ""; val2.result.displayText = "Ordered " + newSuit.unlockableName + " suits! Your new balance is [playerCredits].\n\n"; val2.result.clearPreviousText = true; val2.result.shipUnlockableID = unlockableID; val2.result.buyUnlockable = true; val2.result.itemCost = price; val2.result.terminalEvent = ""; CompatibleNoun val3 = new CompatibleNoun(); val3.noun = ScriptableObject.CreateInstance<TerminalKeyword>(); val3.noun.word = "deny"; val3.noun.isVerb = true; if ((Object)(object)cancelPurchase == (Object)null) { cancelPurchase = ScriptableObject.CreateInstance<TerminalNode>(); } val3.result = cancelPurchase; ((Object)val3.result).name = "MoreSuitsCancelPurchase"; val3.result.displayText = "Cancelled order.\n"; newSuit.shopSelectionNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { val2, val3 }; TerminalKeyword val4 = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val4).name = newSuit.unlockableName + "Suit"; val4.word = newSuit.unlockableName.ToLower() + " suit"; val4.defaultVerb = buyKeyword; CompatibleNoun val5 = new CompatibleNoun(); val5.noun = val4; val5.result = newSuit.shopSelectionNode; List<CompatibleNoun> list = buyKeyword.compatibleNouns.ToList(); list.Add(val5); buyKeyword.compatibleNouns = list.ToArray(); List<TerminalKeyword> list2 = val.terminalNodes.allKeywords.ToList(); list2.Add(val4); list2.Add(val2.noun); list2.Add(val3.noun); val.terminalNodes.allKeywords = list2.ToArray(); return newSuit; } public static bool TryParseVector4(string input, out Vector4 vector) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) vector = Vector4.zero; string[] array = input.Split(','); if (array.Length == 4 && float.TryParse(array[0], out var result) && float.TryParse(array[1], out var result2) && float.TryParse(array[2], out var result3) && float.TryParse(array[3], out var result4)) { vector = new Vector4(result, result2, result3, result4); return true; } return false; } }
plugins/Pinger.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using LC_API.ServerAPI; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Pinger.Overrider; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Pinger")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Pings Player")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Pinger")] [assembly: AssemblyTitle("Pinger")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 Pinger { internal struct CustomScanNode { public long created { get; set; } public ScanNodeProperties scanNode { get; set; } public string owner { get; set; } } [JsonObject(/*Could not decode attribute arguments.*/)] internal class PingData { [JsonProperty] public float x { get; set; } [JsonProperty] public float y { get; set; } [JsonProperty] public float z { get; set; } [JsonProperty] public long created { get; set; } [JsonProperty] public string owner { get; set; } [JsonProperty] public bool isDanger { get; set; } } [BepInPlugin("Pinger", "Pinger", "1.0.0")] public class Plugin : BaseUnityPlugin { private const string SIGNATURE = "player_ping"; private const int LIFESPAN = 10000; private Harmony _harmony; private ScanNodeProperties _scanNodeMaster; private LinkedList<CustomScanNode> _scanNodes = new LinkedList<CustomScanNode>(); private static bool _isPatched; private static bool _isPatching; private static PlayerControllerB _mainPlayer; private static HUDManager _hudManager; public static Plugin Instance { get; private set; } private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown Instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Pinger is loaded!"); _harmony = new Harmony("Pinger"); _harmony.PatchAll(typeof(StartOfRound_Awake)); _harmony.PatchAll(typeof(KeyboardPing)); StartLogicLoop(); } private async void StartLogicLoop() { while ((Object)(object)StartOfRound.Instance == (Object)null) { await Task.Delay(1000); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"StartOfRound.Instance found..."); _mainPlayer = StartOfRound.Instance.localPlayerController; while ((Object)(object)_mainPlayer == (Object)null) { await Task.Delay(250); _mainPlayer = StartOfRound.Instance.localPlayerController; } while ((Object)(object)_hudManager == (Object)null) { await Task.Delay(250); _hudManager = HUDManager.Instance; } _isPatched = true; handleIncomingPings(); } private void handleIncomingPings() { Networking.GetString = (Action<string, string>)Delegate.Combine(Networking.GetString, (Action<string, string>)delegate(string message, string signature) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (signature.Equals("player_ping")) { PingData pingData = JsonConvert.DeserializeObject<PingData>(message); if (pingData == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Failed to parse ping data"); } else { ((BaseUnityPlugin)this).Logger.LogMessage((object)$"Received ping from {pingData.owner} at {pingData.x} {pingData.y} {pingData.z}"); float x = pingData.x; float y = pingData.y; float z = pingData.z; RaycastHit hit = default(RaycastHit); createPing(x, y, z, in hit, pingData.isDanger, pingData.owner); } } }); } private void DeletePings(string owner) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) ScanNodeProperties[] array = Object.FindObjectsByType<ScanNodeProperties>((FindObjectsSortMode)0); for (LinkedListNode<CustomScanNode> linkedListNode = _scanNodes.First; linkedListNode != null; linkedListNode = linkedListNode.Next) { if (!((Object)(object)linkedListNode.Value.scanNode == (Object)null)) { if (linkedListNode.Value.owner != owner) { Debug.Log((object)$"Skipping ping at {((Component)linkedListNode.Value.scanNode).transform.position} (Predicate failed: {linkedListNode.Value.owner} != {owner})"); } else { Debug.Log((object)$"Deleting ping at {((Component)linkedListNode.Value.scanNode).transform.position}"); Object.Destroy((Object)(object)linkedListNode.Value.scanNode); for (int i = 0; i < array.Length; i++) { if (((Component)array[i]).transform.position == ((Component)linkedListNode.Value.scanNode).transform.position) { Object.Destroy((Object)(object)array[i]); break; } } } } } } private async void checkAndDeleteOldPings() { int lifespan = 10000; while (true) { await Task.Delay(1000); long now = DateTimeOffset.Now.ToUnixTimeMilliseconds(); for (LinkedListNode<CustomScanNode> node = _scanNodes.First; node != null; node = node.Next) { if (!((Object)(object)node.Value.scanNode == (Object)null) && now - node.Value.created > lifespan) { ((BaseUnityPlugin)this).Logger.LogMessage((object)$"Deleting ping at {((Component)node.Value.scanNode).transform.position}"); Object.Destroy((Object)(object)node.Value.scanNode); _scanNodes.Remove(node); } } } } private void OnDestroy() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) ScanNodeProperties[] array = Object.FindObjectsByType<ScanNodeProperties>((FindObjectsSortMode)0); for (LinkedListNode<CustomScanNode> linkedListNode = _scanNodes.First; linkedListNode != null; linkedListNode = linkedListNode.Next) { Object.Destroy((Object)(object)linkedListNode.Value.scanNode); for (int i = 0; i < array.Length; i++) { if (((Component)array[i]).transform.position == ((Component)linkedListNode.Value.scanNode).transform.position) { Object.Destroy((Object)(object)array[i]); break; } } } } public bool createPingWherePlayerIsLooking(bool is_danger = false) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_mainPlayer == (Object)null || (Object)(object)_hudManager == (Object)null) { if (_isPatching) { return false; } StartLogicLoop(); _isPatching = true; return false; } float x = ((Component)_mainPlayer.gameplayCamera).transform.position.x; float y = ((Component)_mainPlayer.gameplayCamera).transform.position.y; float z = ((Component)_mainPlayer.gameplayCamera).transform.position.z; RaycastHit hit = shootRay(x, y, z); float x2 = ((RaycastHit)(ref hit)).point.x; float y2 = ((RaycastHit)(ref hit)).point.y; float z2 = ((RaycastHit)(ref hit)).point.z; ((BaseUnityPlugin)this).Logger.LogMessage((object)("Creating Ping on the surface of " + ((Object)((RaycastHit)(ref hit)).transform).name)); CustomScanNode customScanNode = createPing(x2, y2, z2, in hit, is_danger); if ((Object)(object)customScanNode.scanNode == (Object)null) { return false; } string text = JsonConvert.SerializeObject((object)new PingData { x = x2, y = y2, z = z2, created = customScanNode.created, owner = _mainPlayer.playerUsername, isDanger = is_danger }); Networking.Broadcast(text, "player_ping"); return true; } private CustomScanNode createPing(float x, float y, float z, in RaycastHit hit) { return createPing(x, y, z, in hit, isDanger: false, _mainPlayer.playerUsername); } private CustomScanNode createPing(float x, float y, float z, in RaycastHit hit, bool isDanger) { return createPing(x, y, z, in hit, isDanger, _mainPlayer.playerUsername); } private CustomScanNode createPing(float x, float y, float z, in RaycastHit hit, string playerName) { return createPing(x, y, z, in hit, isDanger: false, playerName); } private CustomScanNode createPing(float x, float y, float z, in RaycastHit hit, bool isDanger, string playerName) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) if (hasPlayerPinged(playerName)) { DeletePings(playerName); } string headerText = playerName + "'s ping"; string subText = "Player Ping <!>"; ((BaseUnityPlugin)this).Logger.LogMessage((object)$"Creating Ping at : {x} {y} {z}"); ScanNodeProperties[] array = Object.FindObjectsByType<ScanNodeProperties>((FindObjectsSortMode)0); if ((Object)(object)_scanNodeMaster == (Object)null) { if (array.Length == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No scan node master found"); return default(CustomScanNode); } _scanNodeMaster = array[0]; checkAndDeleteOldPings(); } ScanNodeProperties val = Object.Instantiate<ScanNodeProperties>(_scanNodeMaster); ((Object)val).name = "PlayerPing"; val.headerText = headerText; val.subText = subText; ((Component)val).transform.position = new Vector3(x, y, z); val.maxRange = 200; val.minRange = 0; val.requiresLineOfSight = true; if (isDanger) { val.nodeType = 1; val.subText = "DANGER <!>"; } else { val.nodeType = 2; } CustomScanNode customScanNode = default(CustomScanNode); long created = DateTimeOffset.Now.ToUnixTimeMilliseconds(); customScanNode.created = created; customScanNode.scanNode = val; customScanNode.owner = playerName; _scanNodes.AddLast(customScanNode); if ((Object)(object)_hudManager == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"HUDManager is null"); } else if (customScanNode.owner == _mainPlayer.playerUsername) { _hudManager.UIAudio.PlayOneShot(_hudManager.scanSFX); } return customScanNode; } private bool hasPlayerPinged(string name) { for (LinkedListNode<CustomScanNode> linkedListNode = _scanNodes.First; linkedListNode != null; linkedListNode = linkedListNode.Next) { if (linkedListNode.Value.owner == name) { return true; } } return false; } private RaycastHit shootRay(float x, float y, float z) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) float num = 2.5f; Transform transform = ((Component)_mainPlayer.gameplayCamera).transform; Vector3 val = transform.position + transform.forward * num; RaycastHit result = default(RaycastHit); Physics.Raycast(val, transform.forward, ref result, 1000f); return result; } } public static class PluginInfo { public const string PLUGIN_GUID = "Pinger"; public const string PLUGIN_NAME = "Pinger"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Pinger.Overrider { [HarmonyPatch(typeof(StartOfRound), "Awake")] internal class StartOfRound_Awake { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] private static bool Prefix() { Debug.Log((object)"StartOfRound.Awake() is called"); return true; } } [HarmonyPatch] internal class KeyboardPing { private static float lastQPress; private const float PING_RESET = 0.3f; private static bool isWaiting; private static bool pingPressed; private static IEnumerator WaitForNextQ() { if (!isWaiting) { isWaiting = true; yield return (object)new WaitForSeconds(0.3f); if (!pingPressed) { Plugin.Instance.createPingWherePlayerIsLooking(); } isWaiting = false; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void PingCommand(PlayerControllerB __instance) { long num = DateTimeOffset.Now.ToUnixTimeMilliseconds(); bool flag = false; if (!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || __instance.inTerminalMenu || __instance.isTypingChat || __instance.isPlayerDead) { flag = true; } if (flag) { return; } if (((ButtonControl)Keyboard.current.qKey).wasPressedThisFrame) { if (!pingPressed) { pingPressed = true; ((MonoBehaviour)__instance).StartCoroutine(WaitForNextQ()); } else { bool flag2 = Plugin.Instance.createPingWherePlayerIsLooking(is_danger: true); } } else if (pingPressed) { lastQPress += Time.deltaTime; if (lastQPress >= 0.3f) { pingPressed = false; isWaiting = false; lastQPress = 0f; } } } } } namespace Pinger.CircleHelper { public static class Helper { private const string TAG = "[Pinger::CircleHelper]"; public static void debug_DisplayEntireComponentTree(Transform obj) { if ((Object)(object)obj == (Object)null) { return; } int childCount = obj.childCount; if (childCount > 0) { for (int i = 0; i < childCount; i++) { Transform child = obj.GetChild(i); Debug.Log((object)("[Pinger::CircleHelper]: " + ((Object)obj).name + "/" + ((Object)child).name)); debug_DisplayComponent(obj); debug_DisplayEntireComponentTree(child); } Debug.Log((object)("EOF - " + ((Object)obj).name)); } } private static void debug_DisplayComponent(Transform obj) { Debug.Log((object)string.Format("{0}: {1} :: typeof {2}", "[Pinger::CircleHelper]", ((Object)obj).name, ((object)obj).GetType())); } public static Transform debug_GrabInnerCircle(Transform obj) { if ((Object)(object)obj == (Object)null) { return null; } int childCount = obj.childCount; if (childCount <= 0) { return null; } Transform result = null; for (int i = 0; i < childCount; i++) { Transform child = obj.GetChild(i); if (((Object)child).name == "Inner") { result = child; break; } } return result; } } } namespace Pinger.Adder { internal static class Adder { public static void AddToClass<T>(this T obj, Action action) { obj.GetType().GetMethod("AddToClass").Invoke(obj, new object[1] { action }); } } }
plugins/RollingGiant/RollingGiant.dll
Decompiled 2 years ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using RollingGiant.Patches; using RollingGiant.Settings; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.InputSystem; [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("RollingGiant")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RollingGiant")] [assembly: AssemblyTitle("RollingGiant")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] internal class <Module> { static <Module>() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>(); } } 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 RollingGiant { public class NetworkHandler : NetworkBehaviour { private static InputAction _gotoPreviousAiType; private static InputAction _gotoNextAiType; private static InputAction _reloadConfig; public static NetworkHandler Instance { get; private set; } public override void OnNetworkSpawn() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && Object.op_Implicit((Object)(object)Instance)) { ((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true); } Instance = this; InputAction gotoPreviousAiType = _gotoPreviousAiType; if (gotoPreviousAiType != null) { gotoPreviousAiType.Disable(); } InputAction gotoPreviousAiType2 = _gotoPreviousAiType; if (gotoPreviousAiType2 != null) { gotoPreviousAiType2.Dispose(); } _gotoPreviousAiType = new InputAction("gotoPreviousAiType", (InputActionType)1, CustomConfig.GotoPreviousAiTypeKey.Value, (string)null, (string)null, (string)null); _gotoPreviousAiType.Enable(); InputAction gotoNextAiType = _gotoNextAiType; if (gotoNextAiType != null) { gotoNextAiType.Disable(); } InputAction gotoNextAiType2 = _gotoNextAiType; if (gotoNextAiType2 != null) { gotoNextAiType2.Dispose(); } _gotoNextAiType = new InputAction("gotoNextAiType", (InputActionType)1, CustomConfig.GotoNextAiTypeKey.Value, (string)null, (string)null, (string)null); _gotoNextAiType.Enable(); InputAction reloadConfig = _reloadConfig; if (reloadConfig != null) { reloadConfig.Disable(); } InputAction reloadConfig2 = _reloadConfig; if (reloadConfig2 != null) { reloadConfig2.Dispose(); } _reloadConfig = new InputAction("reloadConfig", (InputActionType)1, CustomConfig.ReloadConfigKey.Value, (string)null, (string)null, (string)null); _reloadConfig.Enable(); ((NetworkBehaviour)this).OnNetworkSpawn(); } private void Update() { if (!((NetworkBehaviour)this).IsServer && !((NetworkBehaviour)this).IsHost) { return; } if (_gotoPreviousAiType.WasPressedThisFrame()) { int num = (int)(SyncedInstance<CustomConfig>.Instance.AiType - 1); if (num < 0) { num = Enum.GetValues(typeof(RollingGiantAiType)).Length - 1; } SetNewAiType((RollingGiantAiType)num); } else if (_gotoNextAiType.WasPressedThisFrame()) { int num2 = (int)(SyncedInstance<CustomConfig>.Instance.AiType + 1); if (num2 >= Enum.GetValues(typeof(RollingGiantAiType)).Length) { num2 = 0; } SetNewAiType((RollingGiantAiType)num2); } else if (_reloadConfig.WasPressedThisFrame()) { Plugin.Config.Reload(); SyncedInstance<CustomConfig>.Instance.Reload(); HUDManager.Instance.DisplayTip("Rolling Giant config reloaded", SyncedInstance<CustomConfig>.Instance.AiType.ToString(), false, false, "LC_Tip1"); SetNewAiType(SyncedInstance<CustomConfig>.Instance.AiType); } } private void SetNewAiType(RollingGiantAiType aiType) { SyncedInstance<CustomConfig>.Instance.AiType = aiType; CustomConfig.SetCurrentAi(); EmitSharedServerSettingsClientRpc(); HUDManager.Instance.DisplayTip("Rolling Giant AI changed", aiType.ToString(), false, false, "LC_Tip1"); } [ClientRpc] private void EmitSharedServerSettingsClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4257552972u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4257552972u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { CustomConfig.RequestSync(); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_NetworkHandler() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(4257552972u, new RpcReceiveHandler(__rpc_handler_4257552972)); } private static void __rpc_handler_4257552972(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((NetworkHandler)(object)target).EmitSharedServerSettingsClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "NetworkHandler"; } } public enum RollingGiantAiType { Coilhead, InverseCoilhead, RandomlyMoveWhileLooking, LookingTooLongKeepsAgro, FollowOnceAgro, OnceSeenAgroAfterTimer } [BepInPlugin("nomnomab.rollinggiant", "Rolling Giant", "2.2.1")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "nomnomab.rollinggiant"; public const string PluginName = "Rolling Giant"; public const string PluginVersion = "2.2.1"; private const int SaveFileVersion = 3; public static string PluginDirectory; public static AssetBundle Bundle; public static EnemyType EnemyTypeInside; public static EnemyType EnemyTypeOutside; public static EnemyType EnemyTypeOutsideDaytime; public static TerminalNode EnemyTerminalNode; public static TerminalKeyword EnemyTerminalKeyword; public static AudioClip WalkSound; public static AudioClip[] StopSounds; public static GameObject PlayerRagdoll; public static Item PosterItem; public static Material BlackAndWhiteMaterial; internal static ManualLogSource Log; public static CustomConfig CustomConfig { get; private set; } public static ConfigFile Config { get; private set; } private void Awake() { Config = ((BaseUnityPlugin)this).Config; Log = ((BaseUnityPlugin)this).Logger; PluginDirectory = ((BaseUnityPlugin)this).Info.Location; LoadSettings(); RemoveOldSettings(); LoadAssets(); LoadNetWeaver(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RollingGiant is loaded!"); } private void LoadNetWeaver() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { try { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } catch { Log.LogWarning((object)("NetWeaver is skipping " + type.FullName)); } } } private void LoadSettings() { CustomConfig = new CustomConfig(((BaseUnityPlugin)this).Config); } private void RemoveOldSettings() { int value = ((BaseUnityPlugin)this).Config.Bind<int>("z_Ignore", "__version", 0, "The version of this config file. Do not change this.").Value; if (value != 3) { Log.LogMessage((object)$"Removing old settings... ({value} != {3})"); string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath; string destFileName = configFilePath + ".bak"; File.Copy(configFilePath, destFileName, overwrite: true); File.WriteAllText(configFilePath, ""); ((BaseUnityPlugin)this).Config.Reload(); CustomConfig.Reload(setValues: false); ((BaseUnityPlugin)this).Config.Bind<int>("z_Ignore", "__version", 3, (ConfigDescription)null).Value = 3; CustomConfig.AssignFromSaved(); ((BaseUnityPlugin)this).Config.Save(); } else { Log.LogMessage((object)$"Settings version is up to date ({value} == {3})"); } } private void LoadAssets() { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) try { Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PluginDirectory) ?? throw new Exception("Failed to get directory name!"), "rollinggiant")); EnemyTypeInside = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType.asset"); EnemyTypeOutside = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType_Outside.asset"); EnemyTypeOutsideDaytime = Bundle.LoadAsset<EnemyType>("Assets/RollingGiant/Data/RollingGiant_EnemyType_Outside_Daytime.asset"); NetworkPatches.RegisterPrefab(EnemyTypeInside.enemyPrefab); NetworkPatches.RegisterPrefab(EnemyTypeOutside.enemyPrefab); NetworkPatches.RegisterPrefab(EnemyTypeOutsideDaytime.enemyPrefab); EnemyTerminalNode = Bundle.LoadAsset<TerminalNode>("Assets/RollingGiant/Data/RollingGiant_TerminalNode.asset"); EnemyTerminalKeyword = Bundle.LoadAsset<TerminalKeyword>("Assets/RollingGiant/Data/RollingGiant_TerminalKeyword.asset"); } catch (Exception arg) { Log.LogError((object)$"Failed to load asset bundle! {arg}"); } try { WalkSound = Bundle.LoadAsset<AudioClip>("Assets/RollingGiant/Audio/MovingLoop.wav"); StopSounds = (AudioClip[])(object)new AudioClip[5]; for (int i = 0; i < 5; i++) { StopSounds[i] = Bundle.LoadAsset<AudioClip>($"Assets/RollingGiant/Audio/Stopped{i + 1}.wav"); } PlayerRagdoll = Bundle.LoadAsset<GameObject>("Assets/RollingGiant/PlayerRagdollRollingGiant Variant.prefab"); PlayerRagdoll.AddComponent<RollingGiantDeadBody>(); PosterItem = Bundle.LoadAsset<Item>("Assets/RollingGiant/Data/RollingGiant_PosterItem.asset"); Item posterItem = PosterItem; posterItem.rotationOffset += new Vector3(45f, 0f, 0f); Item posterItem2 = PosterItem; posterItem2.positionOffset += new Vector3(-0.1f, -0.12f, 0.15f); Object.Destroy((Object)(object)PosterItem.spawnPrefab.GetComponent<PhysicsProp>()); PosterItem.spawnPrefab.AddComponent<Poster>().Init(); NetworkPatches.RegisterPrefab(PosterItem.spawnPrefab); BlackAndWhiteMaterial = Bundle.LoadAsset<Material>("Assets/RollingGiant/Materials/RollingGiant_Gray.mat"); } catch (Exception arg2) { Log.LogError((object)$"Failed to load assets! {arg2}"); } } } public class Poster : PhysicsProp { public void Init() { ((GrabbableObject)this).grabbable = true; ((GrabbableObject)this).itemProperties = Plugin.PosterItem; ((GrabbableObject)this).isInFactory = true; ((GrabbableObject)this).mainObjectRenderer = ((Component)this).GetComponent<MeshRenderer>(); ((GrabbableObject)this).grabbableToEnemies = true; } protected override void __initializeVariables() { ((PhysicsProp)this).__initializeVariables(); } protected internal override string __getTypeName() { return "Poster"; } } public class RollingGiantAI : EnemyAI { private const float ROAMING_AUDIO_PERCENT = 0.4f; [SerializeField] private AISearchRoutine _searchForPlayers; [SerializeField] private Collider _mainCollider; [SerializeField] private AudioClip[] _stopNoises; private AudioSource _rollingSFX; private NetworkVariable<float> _velocity = new NetworkVariable<float>(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private float _timeSinceHittingPlayer; private bool _wantsToChaseThisClient; private bool _hasEnteredChaseState; private bool _wasStopped; private bool _wasFeared; private bool _isAgro; private float _lastSpeed; private float _audioFade; private float _waitTimer; private float _moveTimer; private float _lookTimer; private float _agroTimer; private float _springVelocity; private static SharedAiSettings _sharedAiSettings => CustomConfig.SharedAiSettings; private static float NextDouble() { if (!Object.op_Implicit((Object)(object)RoundManager.Instance) || RoundManager.Instance.LevelRandom == null) { Plugin.Log.LogWarning((object)"Missing RoundManager or LevelRandom, in dev level?"); return Random.value; } return (float)RoundManager.Instance.LevelRandom.NextDouble(); } public override void Start() { ((EnemyAI)this).Start(); Init(); if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsOwner) { AssignInitData_LocalClient(); } } private void Init() { base.agent = ((Component)this).gameObject.GetComponentInChildren<NavMeshAgent>(); _rollingSFX = ((Component)((Component)this).transform.Find("RollingSFX")).GetComponent<AudioSource>(); AudioMixerGroup outputAudioMixerGroup = SoundManager.Instance.diageticMixer.outputAudioMixerGroup; _rollingSFX.outputAudioMixerGroup = outputAudioMixerGroup; base.creatureVoice.outputAudioMixerGroup = outputAudioMixerGroup; base.creatureSFX.outputAudioMixerGroup = outputAudioMixerGroup; _rollingSFX.loop = true; _rollingSFX.clip = Plugin.WalkSound; float time = NextDouble() * Plugin.WalkSound.length; float pitch = Mathf.Lerp(0.96f, 1.05f, NextDouble()); _rollingSFX.time = time; _rollingSFX.pitch = pitch; _rollingSFX.volume = 0f; _rollingSFX.Play(); } public override void DaytimeEnemyLeave() { ((EnemyAI)this).DaytimeEnemyLeave(); Renderer[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (!(((Object)val).name == "object_3")) { val.sharedMaterial = Plugin.BlackAndWhiteMaterial; } } _mainCollider.isTrigger = true; } public override void DoAIInterval() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (base.daytimeEnemyLeaving) { _mainCollider.isTrigger = true; return; } ((EnemyAI)this).DoAIInterval(); if (StartOfRound.Instance.livingPlayers == 0 || base.isEnemyDead) { return; } switch (base.currentBehaviourStateIndex) { case 0: { for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i]; if (((EnemyAI)this).PlayerIsTargetable(val, false, base.isOutside) && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((Component)val.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && (double)Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < 30.0) { ((EnemyAI)this).SwitchToBehaviourState(1); return; } } if (!_searchForPlayers.inProgress) { ((EnemyAI)this).StartSearch(((Component)this).transform.position, _searchForPlayers); } break; } case 1: if (!TargetClosestPlayer()) { base.movingTowardsTargetPlayer = false; if (!_searchForPlayers.inProgress) { ((EnemyAI)this).StartSearch(((Component)this).transform.position, _searchForPlayers); } } else if (_searchForPlayers.inProgress) { ((EnemyAI)this).StopSearch(_searchForPlayers, true); base.movingTowardsTargetPlayer = true; } break; } } public override void Update() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) if (base.daytimeEnemyLeaving) { _mainCollider.isTrigger = true; return; } Vector3 velocity2; if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer) { NetworkVariable<float> velocity = _velocity; velocity2 = base.agent.velocity; velocity.Value = ((Vector3)(ref velocity2)).magnitude; } ((EnemyAI)this).Update(); if (base.isEnemyDead) { return; } velocity2 = base.agent.velocity; _lastSpeed = ((Vector3)(ref velocity2)).magnitude; CalculateAgentSpeed(); _timeSinceHittingPlayer += Time.deltaTime; _mainCollider.isTrigger = !_wasStopped; float value = _velocity.Value; _rollingSFX.volume = Mathf.Lerp(0f, Mathf.Clamp01(0.4f * value + 0.05f), value / _sharedAiSettings.moveSpeed); GameNetworkManager instance = GameNetworkManager.Instance; PlayerControllerB localPlayerController = instance.localPlayerController; if (_wasStopped && !_wasFeared && localPlayerController.HasLineOfSightToPosition(base.eye.position, 70f, 25, -1f)) { _wasFeared = true; float num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position); if (num < 4f) { instance.localPlayerController.JumpToFearLevel(0.9f, true); } else if (num < 9f) { instance.localPlayerController.JumpToFearLevel(0.4f, true); } if (_lastSpeed > 1f) { RoundManager.PlayRandomClip(base.creatureVoice, _stopNoises, false, 1f, 0); } } switch (base.currentBehaviourStateIndex) { case 0: if (_hasEnteredChaseState) { _hasEnteredChaseState = false; _wantsToChaseThisClient = false; _wasStopped = false; _wasFeared = false; _isAgro = false; _agroTimer = 0f; _waitTimer = 0f; _moveTimer = 0f; _lookTimer = 0f; _springVelocity = 0f; base.agent.stoppingDistance = 0f; base.agent.speed = _sharedAiSettings.moveSpeed; base.agent.acceleration = 200f; } if (TargetClosestPlayer() && (Object)(object)base.targetPlayer == (Object)(object)localPlayerController && !_wantsToChaseThisClient) { _wantsToChaseThisClient = true; BeginChasingPlayer_ServerRpc((int)base.targetPlayer.playerClientId); ((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId); } break; case 1: { if (!_hasEnteredChaseState) { _hasEnteredChaseState = true; _wantsToChaseThisClient = false; _wasStopped = false; _wasFeared = false; _isAgro = false; _agroTimer = 0f; _waitTimer = 0f; _moveTimer = 0f; _lookTimer = 0f; _springVelocity = 0f; base.agent.stoppingDistance = 0f; base.agent.speed = 0f; base.agent.acceleration = 200f; } if (!((NetworkBehaviour)this).IsOwner || base.stunNormalizedTimer > 0f) { break; } PlayerControllerB targetPlayer = base.targetPlayer; if (!TargetClosestPlayer()) { EndChasingPlayer_ServerRpc(); break; } if (_wasStopped && _sharedAiSettings.rotateToLookAtPlayer) { if (_lookTimer >= _sharedAiSettings.delayBeforeLookingAtPlayer) { Vector3 position = ((Component)base.targetPlayer).transform.position; Vector3 position2 = ((Component)this).transform.position; Vector3 val = position - position2; val.y = 0f; ((Vector3)(ref val)).Normalize(); Quaternion val2 = Quaternion.LookRotation(val); ((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, val2, Time.deltaTime / _sharedAiSettings.lookAtPlayerDuration); } } else if (!_wasStopped) { _ = _sharedAiSettings.rotateToLookAtPlayer; } PlayerControllerB closestPlayer; switch (_sharedAiSettings.aiType) { case RollingGiantAiType.Coilhead: if (AmIBeingLookedAt(out closestPlayer)) { _wasStopped = true; return; } break; case RollingGiantAiType.InverseCoilhead: if (!AmIBeingLookedAt(out closestPlayer) && _isAgro) { _wasStopped = true; return; } break; case RollingGiantAiType.RandomlyMoveWhileLooking: if (AmIBeingLookedAt(out closestPlayer) && _moveTimer <= 0f) { _wasStopped = true; return; } break; case RollingGiantAiType.LookingTooLongKeepsAgro: if (AmIBeingLookedAt(out closestPlayer) && _agroTimer < _sharedAiSettings.lookTimeBeforeAgro) { _wasStopped = true; return; } break; case RollingGiantAiType.OnceSeenAgroAfterTimer: if (_isAgro && _waitTimer >= 0f) { _wasStopped = true; return; } break; } _wasStopped = false; _wasFeared = false; if (!((Object)(object)targetPlayer == (Object)(object)base.targetPlayer) && !((Object)(object)base.targetPlayer != (Object)(object)localPlayerController)) { ((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer); ((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId); } break; } } } public bool TargetClosestPlayer(float bufferDistance = 1.5f, bool requireLineOfSight = false, float viewWidth = 70f) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) base.mostOptimalDistance = 2000f; PlayerControllerB targetPlayer = base.targetPlayer; base.targetPlayer = null; for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++) { if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, base.isOutside) && !((EnemyAI)this).PathIsIntersectedByLineOfSight(((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position, false, false) && (!requireLineOfSight || ((EnemyAI)this).HasLineOfSightToPosition(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, viewWidth, 40, -1f))) { base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position); if ((double)base.tempDist < (double)base.mostOptimalDistance) { base.mostOptimalDistance = base.tempDist; base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i]; } } } if ((Object)(object)base.targetPlayer != (Object)null && (double)bufferDistance > 0.0 && (Object)(object)targetPlayer != (Object)null && (double)Mathf.Abs(base.mostOptimalDistance - Vector3.Distance(((Component)this).transform.position, ((Component)targetPlayer).transform.position)) < (double)bufferDistance) { base.targetPlayer = targetPlayer; } return (Object)(object)base.targetPlayer != (Object)null; } private static float SmoothLerp(float a, float b, float t) { return a + t * t * (b - a); } public override void OnCollideWithPlayer(Collider other) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (base.daytimeEnemyLeaving) { return; } ((EnemyAI)this).OnCollideWithPlayer(other); if (!(_timeSinceHittingPlayer < 0.6f)) { PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false); if (Object.op_Implicit((Object)(object)val)) { _timeSinceHittingPlayer = 0.2f; int num = StartOfRound.Instance.playerRagdolls.IndexOf(Plugin.PlayerRagdoll); val.DamagePlayer(90, true, true, (CauseOfDeath)4, num, false, default(Vector3)); base.agent.speed = 0f; GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true); } } } private void CalculateAgentSpeed() { if (base.stunNormalizedTimer >= 0f) { base.agent.speed = 0f; base.agent.acceleration = 200f; } else if (base.currentBehaviourStateIndex == 0) { base.agent.speed = ((_sharedAiSettings.moveAcceleration == 0f) ? _sharedAiSettings.moveSpeed : Mathf.Lerp(base.agent.speed, _sharedAiSettings.moveSpeed, Time.deltaTime / _sharedAiSettings.moveAcceleration)); base.agent.acceleration = 200f; } else { if (base.currentBehaviourStateIndex != 1) { return; } if (!IsAgentOnNavMesh(((Component)base.agent).gameObject)) { MoveAccelerate(); return; } PlayerControllerB closestPlayer; bool flag = AmIBeingLookedAt(out closestPlayer); if (flag) { _lookTimer += Time.deltaTime; } else { _lookTimer = 0f; } switch (_sharedAiSettings.aiType) { case RollingGiantAiType.Coilhead: if (flag) { MoveDecelerate(); } else { MoveAccelerate(); } break; case RollingGiantAiType.InverseCoilhead: if (!flag && _isAgro) { MoveDecelerate(); break; } MoveAccelerate(); _isAgro = true; break; case RollingGiantAiType.RandomlyMoveWhileLooking: if (flag) { if (_waitTimer <= 0f && _moveTimer <= 0f) { GenerateWaitTime_LocalClient(); } if (_waitTimer > 0f && _moveTimer <= 0f) { MoveDecelerate(); _waitTimer -= Time.deltaTime; if (_waitTimer <= 0f) { GenerateMoveTime_LocalClient(); } break; } } MoveAccelerate(); if (_moveTimer > 0f) { _moveTimer -= Time.deltaTime; if (_moveTimer <= 0f) { GenerateWaitTime_LocalClient(); } } break; case RollingGiantAiType.LookingTooLongKeepsAgro: if (!_isAgro) { if (flag) { _agroTimer = Mathf.SmoothDamp(_agroTimer, _sharedAiSettings.lookTimeBeforeAgro + 0.5f, ref _springVelocity, 0.5f); if (_agroTimer >= _sharedAiSettings.lookTimeBeforeAgro) { _isAgro = true; } MoveDecelerate(); } else { _agroTimer = Mathf.Lerp(_agroTimer, 0f, Time.deltaTime / (_sharedAiSettings.lookTimeBeforeAgro / 2f)); } } else { MoveAccelerate(); } break; case RollingGiantAiType.FollowOnceAgro: if (!_isAgro && flag) { _isAgro = true; MoveDecelerate(); } else { MoveAccelerate(); } break; case RollingGiantAiType.OnceSeenAgroAfterTimer: if (!_isAgro) { if (flag) { _isAgro = true; GenerateWaitTime_LocalClient(); MoveDecelerate(); } } else if (_waitTimer >= 0f) { _waitTimer -= Time.deltaTime; _ = _waitTimer; _ = 0f; MoveDecelerate(); } else { MoveAccelerate(); } break; } } } private void MoveAccelerate() { base.agent.speed = ((_sharedAiSettings.moveAcceleration == 0f) ? _sharedAiSettings.moveSpeed : Mathf.Lerp(base.agent.speed, _sharedAiSettings.moveSpeed, Time.deltaTime / _sharedAiSettings.moveAcceleration)); base.agent.acceleration = Mathf.Lerp(base.agent.acceleration, 200f, Time.deltaTime); } private void MoveDecelerate() { base.agent.speed = ((_sharedAiSettings.moveDeceleration == 0f) ? 0f : Mathf.Lerp(base.agent.speed, 0f, Time.deltaTime / _sharedAiSettings.moveDeceleration)); base.agent.acceleration = 200f; } private bool AmIBeingLookedAt(out PlayerControllerB closestPlayer) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; float num = float.MaxValue; closestPlayer = null; PlayerControllerB[] array = allPlayerScripts; foreach (PlayerControllerB val in array) { if (((EnemyAI)this).PlayerIsTargetable(val, false, base.isOutside) && val.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 1.6f, 68f, 60, -1f)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num2 < num) { num = num2; closestPlayer = val; } } } return Object.op_Implicit((Object)(object)closestPlayer); } private bool IsAgentOnNavMesh(GameObject agentObject) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Vector3 position = agentObject.transform.position; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 3f, -1) && Mathf.Approximately(position.x, ((NavMeshHit)(ref val)).position.x) && Mathf.Approximately(position.z, ((NavMeshHit)(ref val)).position.z)) { return position.y >= ((NavMeshHit)(ref val)).position.y; } return false; } [ServerRpc(RequireOwnership = false)] private void BeginChasingPlayer_ServerRpc(int playerId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(913739805u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerId); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 913739805u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { BeginChasingPlayer_ClientRpc(playerId); } } } [ClientRpc] private void BeginChasingPlayer_ClientRpc(int playerId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2111596117u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerId); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2111596117u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { ((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(1); PlayerControllerB movingTowardsTargetPlayer = StartOfRound.Instance.allPlayerScripts[playerId]; ((EnemyAI)this).SetMovingTowardsTargetPlayer(movingTowardsTargetPlayer); } } } [ServerRpc(RequireOwnership = false)] private void EndChasingPlayer_ServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3771085912u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3771085912u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { EndChasingPlayer_ClientRpc(); } } } [ClientRpc] private void EndChasingPlayer_ClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1947504516u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1947504516u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { ((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(0); } } } [ServerRpc(RequireOwnership = false)] private void GenerateWaitTime_ServerRpc(float waitTime) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2506095827u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref waitTime, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2506095827u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { _waitTimer = waitTime; } } } private void GenerateWaitTime_LocalClient() { GenerateWaitTime_ServerRpc(_waitTimer = Mathf.Lerp(_sharedAiSettings.waitTimeMin, _sharedAiSettings.waitTimeMax, NextDouble())); } [ServerRpc(RequireOwnership = false)] private void GenerateMoveTime_ServerRpc(float moveTime) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2605455828u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref moveTime, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2605455828u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { _moveTimer = moveTime; GenerateMoveTime_ClientRpc(moveTime); } } } private void GenerateMoveTime_LocalClient() { GenerateMoveTime_ServerRpc(_moveTimer = Mathf.Lerp(_sharedAiSettings.randomMoveTimeMin, _sharedAiSettings.randomMoveTimeMax, NextDouble())); } [ClientRpc] private void GenerateMoveTime_ClientRpc(float moveTime) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4167209315u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref moveTime, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4167209315u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { _moveTimer = moveTime; } } } [ServerRpc(RequireOwnership = false)] private void AssignInitData_ServerRpc(float scale) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2584131514u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref scale, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2584131514u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((Component)base.agent).transform.localScale = Vector3.one * scale; AssignInitData_ClientRpc(scale); } } } private void AssignInitData_LocalClient() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) CustomConfig instance = SyncedInstance<CustomConfig>.Instance; float num = Mathf.Lerp(instance.GiantScaleMin, instance.GiantScaleMax, NextDouble()); ((Component)base.agent).transform.localScale = Vector3.one * num; AssignInitData_ServerRpc(num); } [ClientRpc] private void AssignInitData_ClientRpc(float scale) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3644677666u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref scale, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3644677666u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { Init(); ((Component)base.agent).transform.localScale = Vector3.one * scale; } } } protected override void __initializeVariables() { if (_velocity == null) { throw new Exception("RollingGiantAI._velocity cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_velocity).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_velocity, "_velocity"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_velocity); ((EnemyAI)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_RollingGiantAI() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(913739805u, new RpcReceiveHandler(__rpc_handler_913739805)); NetworkManager.__rpc_func_table.Add(2111596117u, new RpcReceiveHandler(__rpc_handler_2111596117)); NetworkManager.__rpc_func_table.Add(3771085912u, new RpcReceiveHandler(__rpc_handler_3771085912)); NetworkManager.__rpc_func_table.Add(1947504516u, new RpcReceiveHandler(__rpc_handler_1947504516)); NetworkManager.__rpc_func_table.Add(2506095827u, new RpcReceiveHandler(__rpc_handler_2506095827)); NetworkManager.__rpc_func_table.Add(2605455828u, new RpcReceiveHandler(__rpc_handler_2605455828)); NetworkManager.__rpc_func_table.Add(4167209315u, new RpcReceiveHandler(__rpc_handler_4167209315)); NetworkManager.__rpc_func_table.Add(2584131514u, new RpcReceiveHandler(__rpc_handler_2584131514)); NetworkManager.__rpc_func_table.Add(3644677666u, new RpcReceiveHandler(__rpc_handler_3644677666)); } private static void __rpc_handler_913739805(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); target.__rpc_exec_stage = (__RpcExecStage)1; ((RollingGiantAI)(object)target).BeginChasingPlayer_ServerRpc(playerId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2111596117(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); target.__rpc_exec_stage = (__RpcExecStage)2; ((RollingGiantAI)(object)target).BeginChasingPlayer_ClientRpc(playerId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3771085912(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((RollingGiantAI)(object)target).EndChasingPlayer_ServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1947504516(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((RollingGiantAI)(object)target).EndChasingPlayer_ClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2506095827(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { float waitTime = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref waitTime, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((RollingGiantAI)(object)target).GenerateWaitTime_ServerRpc(waitTime); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2605455828(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { float moveTime = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref moveTime, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((RollingGiantAI)(object)target).GenerateMoveTime_ServerRpc(moveTime); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4167209315(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { float moveTime = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref moveTime, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)2; ((RollingGiantAI)(object)target).GenerateMoveTime_ClientRpc(moveTime); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2584131514(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { float scale = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref scale, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((RollingGiantAI)(object)target).AssignInitData_ServerRpc(scale); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3644677666(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { float scale = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref scale, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)2; ((RollingGiantAI)(object)target).AssignInitData_ClientRpc(scale); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "RollingGiantAI"; } } public class RollingGiantDeadBody : MonoBehaviour { } public static class Utility { public static object InvokeNotOverride(this MethodInfo methodInfo, object targetObject, params object[] arguments) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 0) { if (arguments != null && arguments.Length != 0) { throw new Exception("Arguments cont doesn't match"); } } else if (parameters.Length != arguments.Length) { throw new Exception("Arguments cont doesn't match"); } Type returnType = null; if (methodInfo.ReturnType != typeof(void)) { returnType = methodInfo.ReturnType; } Type type = targetObject.GetType(); DynamicMethod dynamicMethod = new DynamicMethod("", returnType, new Type[2] { type, typeof(object) }, type); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Ldarg_0); for (int i = 0; i < parameters.Length; i++) { ParameterInfo obj = parameters[i]; iLGenerator.Emit(OpCodes.Ldarg_1); iLGenerator.Emit(OpCodes.Ldc_I4_S, i); iLGenerator.Emit(OpCodes.Ldelem_Ref); Type parameterType = obj.ParameterType; if (parameterType.IsPrimitive) { iLGenerator.Emit(OpCodes.Unbox_Any, parameterType); } else if (!(parameterType == typeof(object))) { iLGenerator.Emit(OpCodes.Castclass, parameterType); } } iLGenerator.Emit(OpCodes.Call, methodInfo); iLGenerator.Emit(OpCodes.Ret); return dynamicMethod.Invoke(null, new object[2] { targetObject, arguments }); } } public static class PluginInfo { public const string PLUGIN_GUID = "RollingGiant"; public const string PLUGIN_NAME = "RollingGiant"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace RollingGiant.Settings { public struct SharedAiSettings : INetworkSerializable { public RollingGiantAiType aiType; public float moveSpeed; public float moveAcceleration; public float moveDeceleration; public bool rotateToLookAtPlayer; public float delayBeforeLookingAtPlayer; public float lookAtPlayerDuration; public float waitTimeMin; public float waitTimeMax; public float randomMoveTimeMin; public float randomMoveTimeMax; public float lookTimeBeforeAgro; public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer<RollingGiantAiType>*)(&serializer))->SerializeValue<RollingGiantAiType>(ref aiType, default(ForEnums)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveSpeed, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveAcceleration, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref moveDeceleration, default(ForPrimitives)); ((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref rotateToLookAtPlayer, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref delayBeforeLookingAtPlayer, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref lookAtPlayerDuration, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref waitTimeMin, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref waitTimeMax, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref randomMoveTimeMin, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref randomMoveTimeMax, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref lookTimeBeforeAgro, default(ForPrimitives)); } public override string ToString() { return $"aiType: {aiType}, moveSpeed: {moveSpeed}, moveAcceleration: {moveAcceleration}, moveDeceleration: {moveDeceleration}, rotateToLookAtPlayer: {rotateToLookAtPlayer}, delayBeforeLookingAtPlayer: {delayBeforeLookingAtPlayer}, lookAtPlayerDuration: {lookAtPlayerDuration}, waitTimeMin: {waitTimeMin}, waitTimeMax: {waitTimeMax}, randomMoveTimeMin: {randomMoveTimeMin}, randomMoveTimeMax: {randomMoveTimeMax}, lookTimeBeforeAgro: {lookTimeBeforeAgro}"; } } [Serializable] public class CustomConfig : SyncedInstance<CustomConfig> { public const string ROLLINGGIANT_ONREQUESTCONFIGSYNC = "RollingGiant_OnRequestConfigSync"; public const string ROLLINGGIANT_ONRECEIVECONFIGSYNC = "RollingGiant_OnReceiveConfigSync"; private static ConfigFile _config; public const string Name1 = "1. General Settings"; public const string Name2 = "2. AI Settings"; public const string AiTypeDescription = "The AI type of the Rolling Giant.\nCoilhead = Coilhead AI\nInverseCoilhead = Move when player is looking at it\nRandomlyMoveWhileLooking = Randomly move while the player is looking at it\nLookingTooLongKeepsAgro = If the player looks at it for too long it doesn't stop chasing\nFollowOnceAgro = Once the player is noticed, the Rolling Giant will follow the player constantly\nOnceSeenAgroAfterTimer = Once the player sees the Rolling Giant, it will chase the player after a timer"; public const string MoveSpeedDescription = "The speed of the Rolling Giant in m/s²."; public const string MoveAccelerationDescription = "How long it takes the Rolling Giant to get to its movement speed. in seconds"; public const string MoveDecelerationDescription = "How long it takes the Rolling Giant to stop moving in seconds."; public const string RotateToLookAtPlayerDescription = "If the Rolling Giant should rotate to look at the player."; public const string DelayBeforeLookingAtPlayerDescription = "The delay before the Rolling Giant looks at the player in seconds."; public const string LookAtPlayerDurationDescription = "The duration the Rolling Giant looks at the player in seconds."; public static SharedAiSettings SharedAiSettings { get; private set; } public static ConfigEntry<string> GotoPreviousAiTypeKey { get; private set; } public static ConfigEntry<string> GotoNextAiTypeKey { get; private set; } public static ConfigEntry<string> ReloadConfigKey { get; private set; } public static ConfigEntry<string> SpawnInEntry { get; private set; } public static ConfigEntry<bool> SpawnInAnyEntry { get; private set; } public static ConfigEntry<int> SpawnInAnyChanceEntry { get; private set; } public static ConfigEntry<bool> CanSpawnInsideEntry { get; private set; } public static ConfigEntry<bool> CanSpawnOutsideEntry { get; private set; } public static ConfigEntry<bool> DisableOutsideAtNightEntry { get; private set; } public static ConfigEntry<string> SpawnPosterInEntry { get; private set; } public float GiantScaleMin { get; private set; } public float GiantScaleMax { get; private set; } public static string SpawnIn { get; private set; } public static bool SpawnInAny { get; private set; } public static int SpawnInAnyChance { get; private set; } public static bool CanSpawnInside { get; private set; } public static bool CanSpawnOutside { get; private set; } public static bool DisableOutsideAtNight { get; private set; } public static string SpawnPosterIn { get; private set; } public RollingGiantAiType AiType { get; internal set; } public float MoveSpeed { get; private set; } public float MoveAcceleration { get; private set; } public float MoveDeceleration { get; private set; } public bool RotateToLookAtPlayer { get; private set; } public float DelayBeforeLookingAtPlayer { get; private set; } public float LookAtPlayerDuration { get; private set; } public float RandomlyMoveWhenLooking_WaitTimeMin { get; private set; } public float RandomlyMoveWhenLooking_WaitTimeMax { get; private set; } public float RandomlyMoveWhenLooking_RandomMoveTimeMin { get; private set; } public float RandomlyMoveWhenLooking_RandomMoveTimeMax { get; private set; } public float LookingTooLongKeepsAgro_LookTimeBeforeAgro { get; private set; } public float OnceSeenAgroAfterTimer_WaitTimeMin { get; private set; } public float OnceSeenAgroAfterTimer_WaitTimeMax { get; private set; } public static ConfigEntry<float> GiantScaleMinEntry { get; private set; } public static ConfigEntry<float> GiantScaleMaxEntry { get; private set; } public static ConfigEntry<RollingGiantAiType> AiTypeEntry { get; private set; } public static ConfigEntry<float> MoveSpeedEntry { get; private set; } public static ConfigEntry<float> MoveAccelerationEntry { get; private set; } public static ConfigEntry<float> MoveDecelerationEntry { get; private set; } public static ConfigEntry<bool> RotateToLookAtPlayerEntry { get; private set; } public static ConfigEntry<float> DelayBeforeLookingAtPlayerEntry { get; private set; } public static ConfigEntry<float> LookAtPlayerDurationEntry { get; private set; } public static ConfigEntry<float> RandomlyMoveWhenLooking_WaitTimeMinEntry { get; private set; } public static ConfigEntry<float> RandomlyMoveWhenLooking_WaitTimeMaxEntry { get; private set; } public static ConfigEntry<float> RandomlyMoveWhenLooking_RandomMoveTimeMinEntry { get; private set; } public static ConfigEntry<float> RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry { get; private set; } public static ConfigEntry<float> LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry { get; private set; } public static ConfigEntry<float> OnceSeenAgroAfterTimer_WaitTimeMinEntry { get; private set; } public static ConfigEntry<float> OnceSeenAgroAfterTimer_WaitTimeMaxEntry { get; private set; } public CustomConfig(ConfigFile config) { _config = config; InitInstance(this); Reload(); } public void Save() { if (_config == null) { throw new NullReferenceException("Config is null."); } _config.Save(); } public void AssignFromSaved() { GiantScaleMinEntry.Value = GiantScaleMin; GiantScaleMaxEntry.Value = GiantScaleMax; SpawnInEntry.Value = SpawnIn; SpawnInAnyEntry.Value = SpawnInAny; SpawnInAnyChanceEntry.Value = SpawnInAnyChance; CanSpawnInsideEntry.Value = CanSpawnInside; CanSpawnOutsideEntry.Value = CanSpawnOutside; DisableOutsideAtNightEntry.Value = DisableOutsideAtNight; SpawnPosterInEntry.Value = SpawnPosterIn; AiTypeEntry.Value = AiType; MoveSpeedEntry.Value = MoveSpeed; MoveAccelerationEntry.Value = MoveAcceleration; MoveDecelerationEntry.Value = MoveDeceleration; RotateToLookAtPlayerEntry.Value = RotateToLookAtPlayer; DelayBeforeLookingAtPlayerEntry.Value = DelayBeforeLookingAtPlayer; LookAtPlayerDurationEntry.Value = LookAtPlayerDuration; RandomlyMoveWhenLooking_WaitTimeMinEntry.Value = RandomlyMoveWhenLooking_WaitTimeMin; RandomlyMoveWhenLooking_WaitTimeMaxEntry.Value = RandomlyMoveWhenLooking_WaitTimeMax; RandomlyMoveWhenLooking_RandomMoveTimeMinEntry.Value = RandomlyMoveWhenLooking_RandomMoveTimeMin; RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry.Value = RandomlyMoveWhenLooking_RandomMoveTimeMax; LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry.Value = LookingTooLongKeepsAgro_LookTimeBeforeAgro; OnceSeenAgroAfterTimer_WaitTimeMinEntry.Value = OnceSeenAgroAfterTimer_WaitTimeMin; OnceSeenAgroAfterTimer_WaitTimeMaxEntry.Value = OnceSeenAgroAfterTimer_WaitTimeMax; } public void Reload(bool setValues = true) { GiantScaleMinEntry = _config.Bind<float>("1. General Settings", "GiantScaleMin", 0.9f, "The minimum scale of the Rolling Giant.\nThis changes how small the Giant can be.\nThis is a multiplier, so 0.5 is half as large."); GiantScaleMaxEntry = _config.Bind<float>("1. General Settings", "GiantScaleMax", 1.1f, "The maximum scale of the Rolling Giant.\nThis changes how big the Giant can be.\nThis is a multiplier, so 2 is twice as large."); SpawnInEntry = _config.Bind<string>("1. General Settings", "SpawnIn", "Vow:45,March:45,Rend:54,Dine:65,Offense:45,Titan:65", "Where the Rolling Giant can spawn.\nSeparate each level with a comma, and put a chance (no decimals) separated by a colon.\nVanilla caps at 100, but you can go farther.\nThis chance is also a weight, not a percentage.\nHigher chance = higher chance to get picked\nThe names are what you see in the terminal\nExample: Vow:6,March:10"); SpawnInAnyEntry = _config.Bind<bool>("1. General Settings", "SpawnInAny", false, "If the Rolling Giant can spawn in any level."); SpawnInAnyChanceEntry = _config.Bind<int>("1. General Settings", "SpawnInAnyChance", 45, "The chance for the Rolling Giant to spawn in any level.\nRequires SpawnInAny to be enabled!\nThis is a weight, not a percentage.\nHigher chance = higher chance to get picked"); CanSpawnInsideEntry = _config.Bind<bool>("1. General Settings", "CanSpawnInside", true, "If the Rolling Giant can spawn inside."); CanSpawnOutsideEntry = _config.Bind<bool>("1. General Settings", "CanSpawnOutside", false, "If the Rolling Giant can spawn outside."); DisableOutsideAtNightEntry = _config.Bind<bool>("1. General Settings", "DisableOutsideAtNight", false, "If the Rolling Giant will turn off if it is outside at night."); SpawnPosterInEntry = _config.Bind<string>("1. General Settings", "SpawnPosterIn", "Vow:12,March:12,Rend:12,Dine:12,Offense:12,Titan:12", "Where the Rolling Giant poster scrap can spawn.\nSeparate each level with a comma, and put a chance separated by a colon.\nVanilla caps at 100, but you can go farther.\nThis chance is also a weight, not a percentage.\nHigher chance = higher chance to get picked\nThe names are what you see in the terminal\nExample: Vow:12,March:12,Rend:12,Dine:12,Offense:12,Titan:12"); if (GotoPreviousAiTypeKey == null) { GotoPreviousAiTypeKey = _config.Bind<string>("Host", "GotoPreviousAiTypeKey", "<Keyboard>/numpad7", "The key to go to the previous AI type. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths"); } if (GotoNextAiTypeKey == null) { GotoNextAiTypeKey = _config.Bind<string>("Host", "GotoNextAiTypeKey", "<Keyboard>/numpad8", "The key to go to the next AI type. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths"); } if (ReloadConfigKey == null) { ReloadConfigKey = _config.Bind<string>("Host", "ReloadConfigKey", "<Keyboard>/numpad9", "The key to reload the config. Does not update spawn conditions. This uses Unity's New Input System's key-bind names.\nhttps://docs.unity3d.com/Packages/[email protected]/manual/Controls.html#control-paths"); } AiTypeEntry = _config.Bind<RollingGiantAiType>("2. AI Settings", "AiType", RollingGiantAiType.RandomlyMoveWhileLooking, "The AI type of the Rolling Giant.\nCoilhead = Coilhead AI\nInverseCoilhead = Move when player is looking at it\nRandomlyMoveWhileLooking = Randomly move while the player is looking at it\nLookingTooLongKeepsAgro = If the player looks at it for too long it doesn't stop chasing\nFollowOnceAgro = Once the player is noticed, the Rolling Giant will follow the player constantly\nOnceSeenAgroAfterTimer = Once the player sees the Rolling Giant, it will chase the player after a timer"); MoveSpeedEntry = _config.Bind<float>("2. AI Settings", "MoveSpeed", 6f, "The speed of the Rolling Giant in m/s²."); MoveAccelerationEntry = _config.Bind<float>("2. AI Settings", "MoveAcceleration", 2f, "How long it takes the Rolling Giant to get to its movement speed. in seconds"); MoveDecelerationEntry = _config.Bind<float>("2. AI Settings", "MoveDeceleration", 0.5f, "How long it takes the Rolling Giant to stop moving in seconds."); RotateToLookAtPlayerEntry = _config.Bind<bool>("2. AI Settings", "RotateToLookAtPlayer", true, "If the Rolling Giant should rotate to look at the player."); DelayBeforeLookingAtPlayerEntry = _config.Bind<float>("2. AI Settings", "DelayBeforeLookingAtPlayer", 2f, "The delay before the Rolling Giant looks at the player in seconds."); LookAtPlayerDurationEntry = _config.Bind<float>("2. AI Settings", "LookAtPlayerDuration", 3f, "The duration the Rolling Giant looks at the player in seconds."); RandomlyMoveWhenLooking_WaitTimeMinEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "WaitTimeMin", 1f, "The minimum duration in seconds that the Rolling Giant waits before moving again."); RandomlyMoveWhenLooking_WaitTimeMaxEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "WaitTimeMax", 3f, "The maximum duration in seconds that the Rolling Giant waits before moving again."); RandomlyMoveWhenLooking_RandomMoveTimeMinEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "RandomMoveTimeMin", 1f, "The minimum duration in seconds that the Rolling Giant moves for."); RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry = _config.Bind<float>("AI.RandomlyMoveWhenLooking", "RandomMoveTimeMax", 3f, "The maximum duration in seconds that the Rolling Giant moves for."); LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry = _config.Bind<float>("AI.LookingTooLongKeepsAgro", "LookTimeBeforeAgro", 10f, "How long the player can look at the Rolling Giant before it starts chasing in seconds."); OnceSeenAgroAfterTimer_WaitTimeMinEntry = _config.Bind<float>("AI.OnceSeenAgroAfterTimer", "WaitTimeMin", 30f, "The minimum duration in seconds the Rolling Giant waits before chasing the player."); OnceSeenAgroAfterTimer_WaitTimeMaxEntry = _config.Bind<float>("AI.OnceSeenAgroAfterTimer", "WaitTimeMax", 60f, "The minimum duration in seconds the Rolling Giant waits before chasing the player."); if (setValues) { GiantScaleMin = GiantScaleMinEntry.Value; GiantScaleMax = GiantScaleMaxEntry.Value; SpawnIn = SpawnInEntry.Value; SpawnInAny = SpawnInAnyEntry.Value; SpawnInAnyChance = SpawnInAnyChanceEntry.Value; CanSpawnInside = CanSpawnInsideEntry.Value; CanSpawnOutside = CanSpawnOutsideEntry.Value; DisableOutsideAtNight = DisableOutsideAtNightEntry.Value; SpawnPosterIn = SpawnPosterInEntry.Value; AiType = AiTypeEntry.Value; MoveSpeed = MoveSpeedEntry.Value; MoveAcceleration = MoveAccelerationEntry.Value; MoveDeceleration = MoveDecelerationEntry.Value; RotateToLookAtPlayer = RotateToLookAtPlayerEntry.Value; DelayBeforeLookingAtPlayer = DelayBeforeLookingAtPlayerEntry.Value; LookAtPlayerDuration = LookAtPlayerDurationEntry.Value; RandomlyMoveWhenLooking_WaitTimeMin = RandomlyMoveWhenLooking_WaitTimeMinEntry.Value; RandomlyMoveWhenLooking_WaitTimeMax = RandomlyMoveWhenLooking_WaitTimeMaxEntry.Value; RandomlyMoveWhenLooking_RandomMoveTimeMin = RandomlyMoveWhenLooking_RandomMoveTimeMinEntry.Value; RandomlyMoveWhenLooking_RandomMoveTimeMax = RandomlyMoveWhenLooking_RandomMoveTimeMaxEntry.Value; LookingTooLongKeepsAgro_LookTimeBeforeAgro = LookingTooLongKeepsAgro_LookTimeBeforeAgroEntry.Value; OnceSeenAgroAfterTimer_WaitTimeMin = OnceSeenAgroAfterTimer_WaitTimeMinEntry.Value; OnceSeenAgroAfterTimer_WaitTimeMax = OnceSeenAgroAfterTimer_WaitTimeMaxEntry.Value; SetCurrentAi(); } Plugin.Log.LogInfo((object)"Config reloaded."); } public static SharedAiSettings GetSharedAiSettings() { SharedAiSettings result = default(SharedAiSettings); result.aiType = SyncedInstance<CustomConfig>.Instance.AiType; result.moveSpeed = SyncedInstance<CustomConfig>.Instance.MoveSpeed; result.moveAcceleration = SyncedInstance<CustomConfig>.Instance.MoveAcceleration; result.moveDeceleration = SyncedInstance<CustomConfig>.Instance.MoveDeceleration; result.rotateToLookAtPlayer = SyncedInstance<CustomConfig>.Instance.RotateToLookAtPlayer; result.delayBeforeLookingAtPlayer = SyncedInstance<CustomConfig>.Instance.DelayBeforeLookingAtPlayer; result.lookAtPlayerDuration = SyncedInstance<CustomConfig>.Instance.LookAtPlayerDuration; return result; } public static void RequestSync() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!SyncedInstance<CustomConfig>.IsClient) { Plugin.Log.LogError((object)"Config sync error: Not a client."); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(SyncedInstance<CustomConfig>.IntSize, (Allocator)2, -1); try { SyncedInstance<CustomConfig>.MessageManager.SendNamedMessage("RollingGiant_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3); Plugin.Log.LogInfo((object)"Config sync request sent."); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } public static void OnRequestSync(ulong clientId, FastBufferReader _) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (!SyncedInstance<CustomConfig>.IsHost) { Plugin.Log.LogError((object)"Config sync error: Not a host."); return; } Plugin.Log.LogInfo((object)$"Config sync request received from client: {clientId}"); byte[] array = SyncedInstance<CustomConfig>.SerializeToBytes(SyncedInstance<CustomConfig>.Instance); int num = array.Length; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<CustomConfig>.IntSize, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0); SyncedInstance<CustomConfig>.MessageManager.SendNamedMessage("RollingGiant_OnReceiveConfigSync", clientId, val, (NetworkDelivery)4); Plugin.Log.LogInfo((object)$"Config sync sent to client: {clientId}"); } catch (Exception arg) { Plugin.Log.LogError((object)$"Error occurred syncing config with client: {clientId}\n{arg}"); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } public static void OnReceiveSync(ulong _, FastBufferReader reader) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<CustomConfig>.IntSize)) { Plugin.Log.LogError((object)"Config sync error: Could not begin reading buffer."); return; } int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (!((FastBufferReader)(ref reader)).TryBeginRead(num)) { Plugin.Log.LogError((object)"Config sync error: Host could not sync."); return; } byte[] data = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0); SyncedInstance<CustomConfig>.SyncInstance(data); SetCurrentAi(); Plugin.Log.LogInfo((object)"Successfully synced config with host."); } public static void SetCurrentAi() { SharedAiSettings sharedAiSettings2; switch (SyncedInstance<CustomConfig>.Instance.AiType) { case RollingGiantAiType.Coilhead: sharedAiSettings2 = GetSharedAiSettings(); break; case RollingGiantAiType.InverseCoilhead: sharedAiSettings2 = GetSharedAiSettings(); break; case RollingGiantAiType.RandomlyMoveWhileLooking: { SharedAiSettings sharedAiSettings = GetSharedAiSettings(); sharedAiSettings.waitTimeMin = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_WaitTimeMin; sharedAiSettings.waitTimeMax = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_WaitTimeMax; sharedAiSettings.randomMoveTimeMin = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_RandomMoveTimeMin; sharedAiSettings.randomMoveTimeMax = SyncedInstance<CustomConfig>.Instance.RandomlyMoveWhenLooking_RandomMoveTimeMax; sharedAiSettings2 = sharedAiSettings; break; } case RollingGiantAiType.LookingTooLongKeepsAgro: { SharedAiSettings sharedAiSettings = GetSharedAiSettings(); sharedAiSettings.lookTimeBeforeAgro = SyncedInstance<CustomConfig>.Instance.LookingTooLongKeepsAgro_LookTimeBeforeAgro; sharedAiSettings2 = sharedAiSettings; break; } case RollingGiantAiType.FollowOnceAgro: sharedAiSettings2 = GetSharedAiSettings(); break; case RollingGiantAiType.OnceSeenAgroAfterTimer: { SharedAiSettings sharedAiSettings = GetSharedAiSettings(); sharedAiSettings.waitTimeMin = SyncedInstance<CustomConfig>.Instance.OnceSeenAgroAfterTimer_WaitTimeMin; sharedAiSettings.waitTimeMax = SyncedInstance<CustomConfig>.Instance.OnceSeenAgroAfterTimer_WaitTimeMax; sharedAiSettings2 = sharedAiSettings; break; } default: throw new ArgumentOutOfRangeException(); } SharedAiSettings = sharedAiSettings2; Plugin.Log.LogInfo((object)$"Current AI type: {SharedAiSettings}"); } } public class GeneralSettings { public const string Name = "1. General Settings"; public ConfigEntry<float> ChanceForGiant; public ConfigEntry<float> GiantScaleMin; public ConfigEntry<float> GiantScaleMax; public ConfigEntry<bool> SpawnInAllLevels; public ConfigEntry<bool> SpawnInLevelsWithCoilHead; public ConfigEntry<bool> SpawnInside; public ConfigEntry<bool> SpawnDaytime; public ConfigEntry<bool> SpawnOutside; public ConfigEntry<int> Version; public ConfigEntry<string> GotoPreviousAiTypeKey; public ConfigEntry<string> GotoNextAiTypeKey; public GeneralSettings(ConfigFile configFile) { ChanceForGiant = configFile.Bind<float>("1. General Settings", "ChanceForGiant", 0.4f, "0.0-1.0: Chance for a Rolling Giant to spawn. Higher means more chances for a Rolling Giant."); GiantScaleMin = configFile.Bind<float>("1. General Settings", "GiantScaleMin", 1f, "The minimum scale of the Rolling Giant."); GiantScaleMax = configFile.Bind<float>("1. General Settings", "GiantScaleMax", 1f, "The maximum scale of the Rolling Giant."); SpawnInAllLevels = configFile.Bind<bool>("1. General Settings", "SpawnInAllLevels", false, "If the Rolling Giant should spawn in all levels."); SpawnInLevelsWithCoilHead = configFile.Bind<bool>("1. General Settings", "SpawnInLevelsWithCoilHead", true, "If the Rolling Giant should spawn in levels with a Coilhead."); SpawnInside = configFile.Bind<bool>("1. General Settings", "SpawnInside", true, "If the Rolling Giant should spawn inside."); SpawnDaytime = configFile.Bind<bool>("1. General Settings", "SpawnDaytime", false, "If the Rolling Giant should spawn during the day."); SpawnOutside = configFile.Bind<bool>("1. General Settings", "SpawnOutside", false, "If the Rolling Giant should spawn outside."); Version = configFile.Bind<int>("z_Ignore", "__version", 0, "The version of this config file. Do not change this."); GotoPreviousAiTypeKey = configFile.Bind<string>("Dev", "GotoPreviousAiTypeKey", "<Keyboard>/numpad7", "The key to go to the previous AI type. This uses Unity's New Input System's key-bind names."); GotoNextAiTypeKey = configFile.Bind<string>("Dev", "GotoNextAiTypeKey", "<Keyboard>/numpad9", "The key to go to the next AI type. This uses Unity's New Input System's key-bind names."); } public float GetRandomScale(Random rng) { float num = (float)rng.NextDouble(); float value = GiantScaleMin.Value; float value2 = GiantScaleMax.Value; return Mathf.Lerp(value, value2, num); } } [Serializable] public class SyncedInstance<T> { [NonSerialized] protected static int IntSize = 4; internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager; internal static bool IsClient => NetworkManager.Singleton.IsClient; internal static bool IsHost => NetworkManager.Singleton.IsHost; public static T Default { get; private set; } public static T Instance { get; private set; } public static bool Synced { get; internal set; } protected void InitInstance(T instance) { Default = instance; Instance = instance; IntSize = 4; } internal static void SyncInstance(byte[] data) { Instance = DeserializeFromBytes(data); Synced = true; } internal static void RevertSync() { Instance = Default; Synced = false; } public static byte[] SerializeToBytes(T val) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream memoryStream = new MemoryStream(); try { binaryFormatter.Serialize(memoryStream, val); return memoryStream.ToArray(); } catch (Exception arg) { Plugin.Log.LogError((object)$"Error serializing instance: {arg}"); return null; } } public static T DeserializeFromBytes(byte[] data) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream serializationStream = new MemoryStream(data); try { return (T)binaryFormatter.Deserialize(serializationStream); } catch (Exception arg) { Plugin.Log.LogError((object)$"Error deserializing instance: {arg}"); return default(T); } } } } namespace RollingGiant.Patches { [HarmonyPatch] public static class EnemyPatches { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void RegisterEnemy(StartOfRound __instance) { //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown (string, int)[] levelChances = GetLevelChances(CustomConfig.SpawnIn); (string, int)[] levelChances2 = GetLevelChances(CustomConfig.SpawnPosterIn); if (!__instance.allItemsList.itemsList.Contains(Plugin.PosterItem)) { __instance.allItemsList.itemsList.Add(Plugin.PosterItem); } bool spawnInAny = CustomConfig.SpawnInAny; SelectableLevel[] levels = __instance.levels; foreach (SelectableLevel val in levels) { try { string levelName = val.PlanetName.ToLower().Replace(" ", string.Empty); (string, int)[] array = levelChances; for (int j = 0; j < array.Length; j++) { var (value, num) = array[j]; if (!spawnInAny && !levelName.Contains(value)) { continue; } if (spawnInAny) { num = CustomConfig.SpawnInAnyChance; } if (!val.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)Plugin.PosterItem)) { (string, int) tuple2 = levelChances2.FirstOrDefault(((string, int) x) => levelName.Contains(x.Item1)); if (!string.IsNullOrEmpty(tuple2.Item1)) { val.spawnableScrap.Add(new SpawnableItemWithRarity { spawnableItem = Plugin.PosterItem, rarity = tuple2.Item2 }); Plugin.Log.LogMessage((object)$"Added {Plugin.PosterItem.itemName} to {val.PlanetName} with chance of {tuple2.Item2}"); } } if (CustomConfig.CanSpawnInside && val.Enemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeInside)) { val.Enemies.Add(new SpawnableEnemyWithRarity { enemyType = Plugin.EnemyTypeInside, rarity = num }); Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutside.enemyName} to {val.PlanetName} with chance of {num} (inside)"); } if (!CustomConfig.DisableOutsideAtNight && CustomConfig.CanSpawnOutside && val.OutsideEnemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeOutside)) { val.OutsideEnemies.Add(new SpawnableEnemyWithRarity { enemyType = Plugin.EnemyTypeOutside, rarity = num }); Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutside.enemyName} to {val.PlanetName} with chance of {num} (outside)"); } if (CustomConfig.DisableOutsideAtNight && CustomConfig.CanSpawnOutside && val.DaytimeEnemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeOutsideDaytime)) { val.DaytimeEnemies.Add(new SpawnableEnemyWithRarity { enemyType = Plugin.EnemyTypeOutsideDaytime, rarity = num }); Plugin.Log.LogMessage((object)$"Added {Plugin.EnemyTypeOutsideDaytime.enemyName} to {val.PlanetName} with chance of {num} (daytime)"); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to add enemy to {val.PlanetName}!\n{arg}"); } } } private static (string, int)[] GetLevelChances(string str) { if (string.IsNullOrEmpty(str)) { return new(string, int)[0]; } return str.Replace(" ", string.Empty).Split(",").Select(delegate(string x) { if (!x.Contains(":")) { return (x.ToLower().Replace(" ", string.Empty), 0); } string[] array = x.Split(":"); if (!int.TryParse(array[1], out var result)) { result = 0; } return (array[0].ToLower().Replace(" ", string.Empty), result); }) .ToArray(); } [HarmonyPatch(typeof(QuickMenuManager), "Debug_SetEnemyDropdownOptions")] [HarmonyPrefix] private static void AddGiantToDebugList(QuickMenuManager __instance) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown SelectableLevel testAllEnemiesLevel = __instance.testAllEnemiesLevel; SpawnableEnemyWithRarity val = testAllEnemiesLevel.Enemies.FirstOrDefault(); if (val == null) { Plugin.Log.LogError((object)"Failed to get first enemy for debug list!"); return; } List<SpawnableEnemyWithRarity> enemies = testAllEnemiesLevel.Enemies; List<SpawnableEnemyWithRarity> outsideEnemies = testAllEnemiesLevel.OutsideEnemies; List<SpawnableEnemyWithRarity> daytimeEnemies = testAllEnemiesLevel.DaytimeEnemies; if (enemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeInside)) { enemies.Add(new SpawnableEnemyWithRarity { enemyType = Plugin.EnemyTypeInside, rarity = val.rarity }); Plugin.Log.LogMessage((object)("Added " + Plugin.EnemyTypeInside.enemyName + " to debug list")); } if (outsideEnemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeOutside)) { outsideEnemies.Add(new SpawnableEnemyWithRarity { enemyType = Plugin.EnemyTypeOutside, rarity = val.rarity }); Plugin.Log.LogMessage((object)("Added " + Plugin.EnemyTypeOutside.enemyName + " to debug list")); } if (daytimeEnemies.All((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType != (Object)(object)Plugin.EnemyTypeOutsideDaytime)) { daytimeEnemies.Add(new SpawnableEnemyWithRarity { enemyType = Plugin.EnemyTypeOutsideDaytime, rarity = val.rarity }); Plugin.Log.LogMessage((object)("Added " + Plugin.EnemyTypeOutsideDaytime.enemyName + " to debug list")); } } } public static class MapPatches { } [HarmonyPatch] public static class NetworkPatches { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequestSync; public static HandleNamedMessageDelegate <1>__OnReceiveSync; } private static readonly List<GameObject> _prefabs = new List<GameObject>(); private static GameObject _networkPrefab; public static void RegisterPrefab(GameObject prefab) { _prefabs.Add(prefab); } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] private static void RegisterPrefabs() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown foreach (GameObject prefab in _prefabs) { NetworkManager.Singleton.AddNetworkPrefab(prefab); } GameObject val = (GameObject)Plugin.Bundle.LoadAsset("Assets/RollingGiant/NetworkObjectRoot.prefab"); val.AddComponent<NetworkHandler>(); _networkPrefab = val; NetworkManager.Singleton.AddNetworkPrefab(val); } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "Awake")] private static void SpawnNetworkHandler() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) { Object.Instantiate<GameObject>(_networkPrefab, Vector3.zero, Quaternion.identity).GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "Con
plugins/ShipLoot/ShipLoot.dll
Decompiled 2 years agousing System; using System.Collections; 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 System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ShipLoot")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("ShipLoot")] [assembly: AssemblyCopyright("Copyright © tinyhoot 2023")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ShipLoot { [BepInPlugin("com.github.tinyhoot.ShipLoot", "ShipLoot", "1.0")] internal class ShipLoot : BaseUnityPlugin { public const string GUID = "com.github.tinyhoot.ShipLoot"; public const string NAME = "ShipLoot"; public const string VERSION = "1.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.github.tinyhoot.ShipLoot").PatchAll(Assembly.GetExecutingAssembly()); } } } namespace ShipLoot.Patches { [HarmonyPatch] internal class HudManagerPatcher { private static GameObject _totalCounter; private static TextMeshProUGUI _textMesh; private static float _displayTimeLeft; private const float DisplayTime = 5f; [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] private static void OnScan(HUDManager __instance, CallbackContext context) { if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && __instance.CanPlayerScan() && !(__instance.playerPingingScan > -0.5f) && (StartOfRound.Instance.inShipPhase || GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom)) { if (!Object.op_Implicit((Object)(object)_totalCounter)) { CopyValueCounter(); } float num = CalculateLootValue(); ((TMP_Text)_textMesh).text = $"SHIP: ${num:F0}"; _displayTimeLeft = 5f; if (!_totalCounter.activeSelf) { ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(ShipLootCoroutine()); } } } private static IEnumerator ShipLootCoroutine() { _totalCounter.SetActive(true); while (_displayTimeLeft > 0f) { float displayTimeLeft = _displayTimeLeft; _displayTimeLeft = 0f; yield return (object)new WaitForSeconds(displayTimeLeft); } _totalCounter.SetActive(false); } private static float CalculateLootValue() { List<GrabbableObject> list = (from obj in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>() where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem" select obj).ToList(); ShipLoot.Log.LogDebug((object)"Calculating total ship scrap value."); CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)list, (Action<GrabbableObject>)delegate(GrabbableObject scrap) { ShipLoot.Log.LogDebug((object)$"{((Object)scrap).name} - ${scrap.scrapValue}"); }); return list.Sum((GrabbableObject scrap) => scrap.scrapValue); } private static void CopyValueCounter() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter"); if (!Object.op_Implicit((Object)(object)val)) { ShipLoot.Log.LogError((object)"Failed to find ValueCounter object to copy!"); } _totalCounter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false); _totalCounter.transform.Translate(0f, 1f, 0f); Vector3 localPosition = _totalCounter.transform.localPosition; _totalCounter.transform.localPosition = new Vector3(localPosition.x + 50f, -50f, localPosition.z); _textMesh = _totalCounter.GetComponentInChildren<TextMeshProUGUI>(); } } }
plugins/SignalTranslatorUpgrade.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Linq; 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 Microsoft.CodeAnalysis; 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("SignalTranslatorUpgrade")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Fit more characters into transmissions!")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7da60c7d33bc262e861d680200695ce99d57357b")] [assembly: AssemblyProduct("SignalTranslatorUpgrade")] [assembly: AssemblyTitle("SignalTranslatorUpgrade")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 SignalTranslatorUpgrade { [BepInPlugin("Fredolx.SignalTranslatorUpgrade", "SignalTranslatorUpgrade", "1.0.0")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Logger; public static string TransmitMessage { get; set; } public static string ClientMessage { get; set; } public static ConfigEntry<int> MaxCharacters { get; set; } private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (Logger == null) { Logger = ((BaseUnityPlugin)this).Logger; } Logger.LogInfo((object)"Plugin SignalTranslatorUpgrade is loaded!"); MaxCharacters = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxMessageLength", 30, "The maximum of characters that should be displayed on the screen when transmitting messages"); new Harmony("SignalTranslatorUpgrade").PatchAll(); } } public static class PluginInfo { public const string PLUGIN_GUID = "SignalTranslatorUpgrade"; public const string PLUGIN_NAME = "SignalTranslatorUpgrade"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace SignalTranslatorUpgrade.Patches { [HarmonyPatch(typeof(HUDManager), "UseSignalTranslatorServerRpc")] public class UseSignalTranslatorServerRpc { private static void Postfix(HUDManager __instance, string signalMessage) { if (signalMessage.Length > 12) { SignalTranslator val = Object.FindObjectOfType<SignalTranslator>(); if (!(Time.realtimeSinceStartup - val.timeLastUsingSignalTranslator < 8f)) { val.timeLastUsingSignalTranslator = Time.realtimeSinceStartup; val.timesSendingMessage++; __instance.UseSignalTranslatorClientRpc(signalMessage, val.timesSendingMessage); Plugin.Logger.LogInfo((object)("ServerRPC Postfix: " + signalMessage)); } } } private static void Prefix(ref string signalMessage, HUDManager __instance) { if (Plugin.TransmitMessage != null) { signalMessage = Plugin.TransmitMessage; Plugin.Logger.LogInfo((object)("ServerRPC Prefix: " + signalMessage)); Plugin.TransmitMessage = null; } } } [HarmonyPatch(typeof(HUDManager), "UseSignalTranslatorClientRpc")] public class UseSignalTranslatorClientRpc { private static void Prefix(string signalMessage) { Plugin.Logger.LogInfo((object)("Client RPC Prefix: " + signalMessage)); Plugin.ClientMessage = signalMessage; } } [HarmonyPatch(typeof(HUDManager), "DisplaySignalTranslatorMessage")] public class DisplaySignalTranslatorMessage { private static void Prefix(ref string signalMessage) { signalMessage = ((Plugin.ClientMessage.Length < Plugin.MaxCharacters.Value) ? Plugin.ClientMessage : Plugin.ClientMessage.Substring(0, Plugin.MaxCharacters.Value)); Plugin.Logger.LogInfo((object)("Display: " + signalMessage)); Plugin.ClientMessage = null; } } [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] public class ParsePlayerSentence { private static bool Prefix(Terminal __instance) { string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded); text = Traverse.Create((object)__instance).Method("RemovePunctuation", new object[1] { text }).GetValue<string>(); string[] array = text.Split(" "); if (array[0] != "transmit") { return true; } Plugin.TransmitMessage = string.Join(" ", array.Skip(1)); return true; } } }
plugins/SkinwalkerMod.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Dissonance.Config; using HarmonyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.Networking; 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("SkinwalkerMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SkinwalkerMod")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("fd4979a2-cef0-46af-8bf8-97e630b11475")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] internal class <Module> { static <Module>() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<float>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<float>(); } } namespace SkinwalkerMod; [BepInPlugin("RugbugRedfern.SkinwalkerMod", "Skinwalker Mod", "1.0.7")] internal class PluginLoader : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("RugbugRedfern.SkinwalkerMod"); private const string modGUID = "RugbugRedfern.SkinwalkerMod"; private const string modVersion = "1.0.7"; private static bool initialized; public static PluginLoader Instance { get; private set; } private void Awake() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown if (initialized) { return; } initialized = true; Instance = this; harmony.PatchAll(Assembly.GetExecutingAssembly()); Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } SkinwalkerLogger.Initialize("RugbugRedfern.SkinwalkerMod"); SkinwalkerLogger.Log("SKINWALKER MOD STARTING UP 1.0.7"); SkinwalkerConfig.InitConfig(); SceneManager.sceneLoaded += SkinwalkerNetworkManagerHandler.ClientConnectInitializer; GameObject val = new GameObject("Skinwalker Mod"); val.AddComponent<SkinwalkerModPersistent>(); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); } public void BindConfig<T>(ref ConfigEntry<T> config, string section, string key, T defaultValue, string description = "") { config = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description); } } internal class SkinwalkerBehaviour : MonoBehaviour { private AudioSource audioSource; public const float PLAY_INTERVAL_MIN = 15f; public const float PLAY_INTERVAL_MAX = 40f; private float nextTimeToPlayAudio; public void Initialize(EnemyAI ai) { audioSource = ai.creatureVoice; SetNextTime(); } private void Update() { if (Time.time > nextTimeToPlayAudio) { SetNextTime(); AudioClip sample = SkinwalkerModPersistent.Instance.GetSample(); if (Object.op_Implicit((Object)(object)sample)) { audioSource.PlayOneShot(sample); } } } private void SetNextTime() { if (SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value <= 0f) { nextTimeToPlayAudio = Time.time + 100000000f; } else { nextTimeToPlayAudio = Time.time + Random.Range(15f, 40f) / SkinwalkerNetworkManager.Instance.VoiceLineFrequency.Value; } } private T CopyComponent<T>(T original, GameObject destination) where T : Component { Type type = ((object)original).GetType(); Component val = destination.AddComponent(type); FieldInfo[] fields = type.GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { fieldInfo.SetValue(val, fieldInfo.GetValue(original)); } return (T)(object)((val is T) ? val : null); } } internal class SkinwalkerConfig { public static ConfigEntry<bool> VoiceEnabled_BaboonHawk; public static ConfigEntry<bool> VoiceEnabled_Bracken; public static ConfigEntry<bool> VoiceEnabled_BunkerSpider; public static ConfigEntry<bool> VoiceEnabled_Centipede; public static ConfigEntry<bool> VoiceEnabled_CoilHead; public static ConfigEntry<bool> VoiceEnabled_EyelessDog; public static ConfigEntry<bool> VoiceEnabled_ForestGiant; public static ConfigEntry<bool> VoiceEnabled_GhostGirl; public static ConfigEntry<bool> VoiceEnabled_GiantWorm; public static ConfigEntry<bool> VoiceEnabled_HoardingBug; public static ConfigEntry<bool> VoiceEnabled_Hygrodere; public static ConfigEntry<bool> VoiceEnabled_Jester; public static ConfigEntry<bool> VoiceEnabled_SporeLizard; public static ConfigEntry<bool> VoiceEnabled_Thumper; public static ConfigEntry<float> VoiceLineFrequency; public static void InitConfig() { PluginLoader.Instance.BindConfig(ref VoiceEnabled_BaboonHawk, "Monster Voices", "Baboon Hawk", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Bracken, "Monster Voices", "Bracken", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_BunkerSpider, "Monster Voices", "Bunker Spider", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Centipede, "Monster Voices", "Centipede", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_CoilHead, "Monster Voices", "Coil Head", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_EyelessDog, "Monster Voices", "Eyeless Dog", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_ForestGiant, "Monster Voices", "Forest Giant", defaultValue: false); PluginLoader.Instance.BindConfig(ref VoiceEnabled_GhostGirl, "Monster Voices", "Ghost Girl", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_GiantWorm, "Monster Voices", "Giant Worm", defaultValue: false); PluginLoader.Instance.BindConfig(ref VoiceEnabled_HoardingBug, "Monster Voices", "Hoarding Bug", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Hygrodere, "Monster Voices", "Hygrodere", defaultValue: false); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Jester, "Monster Voices", "Jester", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_SporeLizard, "Monster Voices", "Spore Lizard", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceEnabled_Thumper, "Monster Voices", "Thumper", defaultValue: true); PluginLoader.Instance.BindConfig(ref VoiceLineFrequency, "Monster Voices", "VoiceLineFrequency", 1f, "1 is the default, and voice lines will occur every " + 15f.ToString("0") + " to " + 40f.ToString("0") + " seconds per enemy. Setting this to 2 means they will occur twice as often, 0.5 means half as often, etc."); SkinwalkerLogger.Log("VoiceEnabled_BaboonHawk" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BaboonHawk.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Bracken" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Bracken.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_BunkerSpider" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_BunkerSpider.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Centipede" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Centipede.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_CoilHead" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_CoilHead.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_EyelessDog" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_EyelessDog.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_ForestGiant" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_ForestGiant.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_GhostGirl" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GhostGirl.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_GiantWorm" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_GiantWorm.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_HoardingBug" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_HoardingBug.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Hygrodere" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Hygrodere.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Jester" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Jester.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_SporeLizard" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_SporeLizard.Value}]"); SkinwalkerLogger.Log("VoiceEnabled_Thumper" + $" VALUE LOADED FROM CONFIG: [{VoiceEnabled_Thumper.Value}]"); SkinwalkerLogger.Log("VoiceLineFrequency" + $" VALUE LOADED FROM CONFIG: [{VoiceLineFrequency.Value}]"); } } internal static class SkinwalkerLogger { internal static ManualLogSource logSource; public static void Initialize(string modGUID) { logSource = Logger.CreateLogSource(modGUID); } public static void Log(object message) { logSource.LogInfo(message); } public static void LogError(object message) { logSource.LogError(message); } } public class SkinwalkerModPersistent : MonoBehaviour { private string audioFolder; private List<AudioClip> cachedAudio = new List<AudioClip>(); private float nextTimeToCheckFolder = 30f; private float nextTimeToCheckEnemies = 30f; private const float folderScanInterval = 8f; private const float enemyScanInterval = 5f; public static SkinwalkerModPersistent Instance { get; private set; } private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) Instance = this; ((Component)this).transform.position = Vector3.zero; SkinwalkerLogger.Log("Skinwalker Mod Object Initialized"); audioFolder = Path.Combine(Application.dataPath, "..", "Dissonance_Diagnostics"); EnableRecording(); if (!Directory.Exists(audioFolder)) { Directory.CreateDirectory(audioFolder); } } private void OnApplicationQuit() { DisableRecording(); } private void EnableRecording() { DebugSettings.Instance.EnablePlaybackDiagnostics = true; DebugSettings.Instance.RecordFinalAudio = true; } private void Update() { if (Time.realtimeSinceStartup > nextTimeToCheckFolder) { nextTimeToCheckFolder = Time.realtimeSinceStartup + 8f; if (!Directory.Exists(audioFolder)) { SkinwalkerLogger.LogError("Audio folder is missing at " + audioFolder); return; } string[] files = Directory.GetFiles(audioFolder); foreach (string text in files) { SkinwalkerLogger.Log("Got audio file path " + text); ((MonoBehaviour)this).StartCoroutine(LoadWavFile(text, delegate(AudioClip audioClip) { cachedAudio.Add(audioClip); })); } } if (!(Time.realtimeSinceStartup > nextTimeToCheckEnemies)) { return; } nextTimeToCheckEnemies = Time.realtimeSinceStartup + 5f; EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>(true); EnemyAI[] array2 = array; SkinwalkerBehaviour skinwalkerBehaviour = default(SkinwalkerBehaviour); foreach (EnemyAI val in array2) { SkinwalkerLogger.Log("IsEnemyEnabled " + ((Object)val).name + " " + IsEnemyEnabled(val)); if (IsEnemyEnabled(val) && !((Component)val).TryGetComponent<SkinwalkerBehaviour>(ref skinwalkerBehaviour)) { ((Component)val).gameObject.AddComponent<SkinwalkerBehaviour>().Initialize(val); } } } private bool IsEnemyEnabled(EnemyAI enemy) { if ((Object)(object)enemy == (Object)null) { return false; } return ((Object)((Component)enemy).gameObject).name switch { "BaboonHawkEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BaboonHawk.Value, "Flowerman(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Bracken.Value, "SandSpider(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_BunkerSpider.Value, "RedLocustBees(Clone)" => false, "Centipede(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Centipede.Value, "SpringMan(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_CoilHead.Value, "MouthDog(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_EyelessDog.Value, "ForestGiant(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_ForestGiant.Value, "DressGirl(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GhostGirl.Value, "SandWorm(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_GiantWorm.Value, "HoarderBug(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_HoardingBug.Value, "Blob(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Hygrodere.Value, "JesterEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Jester.Value, "PufferEnemy(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_SporeLizard.Value, "Crawler(Clone)" => SkinwalkerNetworkManager.Instance.VoiceEnabled_Thumper.Value, "DocileLocustBees(Clone)" => false, "DoublewingedBird(Clone)" => false, _ => true, }; } internal IEnumerator LoadWavFile(string path, Action<AudioClip> callback) { UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20); try { yield return www.SendWebRequest(); if ((int)www.result != 1) { SkinwalkerLogger.LogError("Failed to load WAV file: " + www.error); yield break; } SkinwalkerLogger.Log("Loaded clip from path " + path); AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www); if (audioClip.length > 0.9f) { callback(audioClip); } File.Delete(path); } finally { ((IDisposable)www)?.Dispose(); } } private void DisableRecording() { DebugSettings.Instance.EnablePlaybackDiagnostics = false; DebugSettings.Instance.RecordFinalAudio = false; if (Directory.Exists(audioFolder)) { Directory.Delete(audioFolder, recursive: true); } } public AudioClip GetSample() { if (cachedAudio.Count > 0) { int index = Random.Range(0, cachedAudio.Count - 1); AudioClip result = cachedAudio[index]; cachedAudio.RemoveAt(index); return result; } while (cachedAudio.Count > 200) { cachedAudio.RemoveAt(0); } return null; } public void ClearCache() { cachedAudio.Clear(); } } internal static class SkinwalkerNetworkManagerHandler { internal static void ClientConnectInitializer(Scene sceneName, LoadSceneMode sceneEnum) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (((Scene)(ref sceneName)).name == "SampleSceneRelay") { GameObject val = new GameObject("SkinwalkerNetworkManager"); val.AddComponent<NetworkObject>(); val.AddComponent<SkinwalkerNetworkManager>(); Debug.Log((object)"Initialized SkinwalkerNetworkManager"); } } } internal class SkinwalkerNetworkManager : NetworkBehaviour { public NetworkVariable<bool> VoiceEnabled_BaboonHawk = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Bracken = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_BunkerSpider = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Centipede = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_CoilHead = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_EyelessDog = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_ForestGiant = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_GhostGirl = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_GiantWorm = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_HoardingBug = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Hygrodere = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Jester = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_SporeLizard = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<bool> VoiceEnabled_Thumper = new NetworkVariable<bool>(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public NetworkVariable<float> VoiceLineFrequency = new NetworkVariable<float>(1f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public static SkinwalkerNetworkManager Instance { get; private set; } private void Awake() { Instance = this; NetworkVariable<bool> voiceEnabled_BaboonHawk = VoiceEnabled_BaboonHawk; voiceEnabled_BaboonHawk.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_BaboonHawk.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_BaboonHawk" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_Bracken = VoiceEnabled_Bracken; voiceEnabled_Bracken.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_Bracken.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_Bracken" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_BunkerSpider = VoiceEnabled_BunkerSpider; voiceEnabled_BunkerSpider.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_BunkerSpider.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_BunkerSpider" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_Centipede = VoiceEnabled_Centipede; voiceEnabled_Centipede.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_Centipede.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_Centipede" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_CoilHead = VoiceEnabled_CoilHead; voiceEnabled_CoilHead.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_CoilHead.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_CoilHead" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_EyelessDog = VoiceEnabled_EyelessDog; voiceEnabled_EyelessDog.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_EyelessDog.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_EyelessDog" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_ForestGiant = VoiceEnabled_ForestGiant; voiceEnabled_ForestGiant.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_ForestGiant.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_ForestGiant" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_GhostGirl = VoiceEnabled_GhostGirl; voiceEnabled_GhostGirl.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_GhostGirl.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_GhostGirl" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_GiantWorm = VoiceEnabled_GiantWorm; voiceEnabled_GiantWorm.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_GiantWorm.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_GiantWorm" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_HoardingBug = VoiceEnabled_HoardingBug; voiceEnabled_HoardingBug.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_HoardingBug.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_HoardingBug" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_Hygrodere = VoiceEnabled_Hygrodere; voiceEnabled_Hygrodere.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_Hygrodere.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_Hygrodere" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_Jester = VoiceEnabled_Jester; voiceEnabled_Jester.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_Jester.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_Jester" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_SporeLizard = VoiceEnabled_SporeLizard; voiceEnabled_SporeLizard.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_SporeLizard.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_SporeLizard" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<bool> voiceEnabled_Thumper = VoiceEnabled_Thumper; voiceEnabled_Thumper.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)voiceEnabled_Thumper.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<bool>)delegate(bool prevValue, bool newValue) { SkinwalkerLogger.Log("VoiceEnabled_Thumper" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); NetworkVariable<float> voiceLineFrequency = VoiceLineFrequency; voiceLineFrequency.OnValueChanged = (OnValueChangedDelegate<float>)(object)Delegate.Combine((Delegate?)(object)voiceLineFrequency.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<float>)delegate(float prevValue, float newValue) { SkinwalkerLogger.Log("VoiceLineFrequency" + $" VALUE CHANGED: [prev: {prevValue}] [new: {newValue}]"); }); if (GameNetworkManager.Instance.isHostingGame) { VoiceEnabled_BaboonHawk.Value = SkinwalkerConfig.VoiceEnabled_BaboonHawk.Value; VoiceEnabled_Bracken.Value = SkinwalkerConfig.VoiceEnabled_Bracken.Value; VoiceEnabled_BunkerSpider.Value = SkinwalkerConfig.VoiceEnabled_BunkerSpider.Value; VoiceEnabled_Centipede.Value = SkinwalkerConfig.VoiceEnabled_Centipede.Value; VoiceEnabled_CoilHead.Value = SkinwalkerConfig.VoiceEnabled_CoilHead.Value; VoiceEnabled_EyelessDog.Value = SkinwalkerConfig.VoiceEnabled_EyelessDog.Value; VoiceEnabled_ForestGiant.Value = SkinwalkerConfig.VoiceEnabled_ForestGiant.Value; VoiceEnabled_GhostGirl.Value = SkinwalkerConfig.VoiceEnabled_GhostGirl.Value; VoiceEnabled_GiantWorm.Value = SkinwalkerConfig.VoiceEnabled_GiantWorm.Value; VoiceEnabled_HoardingBug.Value = SkinwalkerConfig.VoiceEnabled_HoardingBug.Value; VoiceEnabled_Hygrodere.Value = SkinwalkerConfig.VoiceEnabled_Hygrodere.Value; VoiceEnabled_Jester.Value = SkinwalkerConfig.VoiceEnabled_Jester.Value; VoiceEnabled_SporeLizard.Value = SkinwalkerConfig.VoiceEnabled_SporeLizard.Value; VoiceEnabled_Thumper.Value = SkinwalkerConfig.VoiceEnabled_Thumper.Value; VoiceLineFrequency.Value = SkinwalkerConfig.VoiceLineFrequency.Value; SkinwalkerLogger.Log("HOST SENDING CONFIG TO CLIENTS"); } SkinwalkerLogger.Log("SkinwalkerNetworkManager Awake"); } public override void OnDestroy() { ((NetworkBehaviour)this).OnDestroy(); SkinwalkerLogger.Log("SkinwalkerNetworkManager OnDestroy"); SkinwalkerModPersistent.Instance?.ClearCache(); } protected override void __initializeVariables() { if (VoiceEnabled_BaboonHawk == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BaboonHawk cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_BaboonHawk).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk, "VoiceEnabled_BaboonHawk"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BaboonHawk); if (VoiceEnabled_Bracken == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Bracken cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Bracken).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Bracken, "VoiceEnabled_Bracken"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Bracken); if (VoiceEnabled_BunkerSpider == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_BunkerSpider cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_BunkerSpider).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider, "VoiceEnabled_BunkerSpider"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_BunkerSpider); if (VoiceEnabled_Centipede == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Centipede cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Centipede).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Centipede, "VoiceEnabled_Centipede"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Centipede); if (VoiceEnabled_CoilHead == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_CoilHead cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_CoilHead).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_CoilHead, "VoiceEnabled_CoilHead"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_CoilHead); if (VoiceEnabled_EyelessDog == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_EyelessDog cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_EyelessDog).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_EyelessDog, "VoiceEnabled_EyelessDog"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_EyelessDog); if (VoiceEnabled_ForestGiant == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_ForestGiant cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_ForestGiant).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_ForestGiant, "VoiceEnabled_ForestGiant"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_ForestGiant); if (VoiceEnabled_GhostGirl == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GhostGirl cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_GhostGirl).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GhostGirl, "VoiceEnabled_GhostGirl"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GhostGirl); if (VoiceEnabled_GiantWorm == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_GiantWorm cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_GiantWorm).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_GiantWorm, "VoiceEnabled_GiantWorm"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_GiantWorm); if (VoiceEnabled_HoardingBug == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_HoardingBug cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_HoardingBug).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_HoardingBug, "VoiceEnabled_HoardingBug"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_HoardingBug); if (VoiceEnabled_Hygrodere == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Hygrodere cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Hygrodere).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Hygrodere, "VoiceEnabled_Hygrodere"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Hygrodere); if (VoiceEnabled_Jester == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Jester cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Jester).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Jester, "VoiceEnabled_Jester"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Jester); if (VoiceEnabled_SporeLizard == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_SporeLizard cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_SporeLizard).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_SporeLizard, "VoiceEnabled_SporeLizard"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_SporeLizard); if (VoiceEnabled_Thumper == null) { throw new Exception("SkinwalkerNetworkManager.VoiceEnabled_Thumper cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceEnabled_Thumper).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceEnabled_Thumper, "VoiceEnabled_Thumper"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceEnabled_Thumper); if (VoiceLineFrequency == null) { throw new Exception("SkinwalkerNetworkManager.VoiceLineFrequency cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)VoiceLineFrequency).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)VoiceLineFrequency, "VoiceLineFrequency"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)VoiceLineFrequency); ((NetworkBehaviour)this).__initializeVariables(); } protected internal override string __getTypeName() { return "SkinwalkerNetworkManager"; } }
plugins/SpectateEnemy.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SpectateEnemy")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0+6a7b6d29bdeedb1393563d8464b7c0602d7b3d10")] [assembly: AssemblyProduct("SpectateEnemy")] [assembly: AssemblyTitle("SpectateEnemy")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.0.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 SpectateEnemy { [BepInPlugin("SpectateEnemy", "SpectateEnemy", "2.0.0")] internal class Plugin : BaseUnityPlugin { public static MethodInfo raycastSpectate; public static MethodInfo displaySpectatorTip; private Harmony harmony; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown harmony = new Harmony("SpectateEnemy"); harmony.PatchAll(); raycastSpectate = AccessTools.Method(typeof(PlayerControllerB), "RaycastSpectateCameraAroundPivot", (Type[])null, (Type[])null); displaySpectatorTip = AccessTools.Method(typeof(HUDManager), "DisplaySpectatorTip", (Type[])null, (Type[])null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SpectateEnemy loaded!"); } } internal class Spectatable : MonoBehaviour { public SpectatableType type = SpectatableType.Enemy; public string enemyName = "Enemy"; } internal enum SpectatableType { Enemy, Turret, Landmine } internal class SpectateEnemies : MonoBehaviour { public static SpectateEnemies Instance; private static readonly Dictionary<string, bool> settings = new Dictionary<string, bool>(); private bool WindowOpen = false; private Rect window = new Rect(10f, 10f, 500f, 300f); public int SpectatedEnemyIndex = -1; public bool SpectatingEnemies = false; public Spectatable[] SpectatorList; private void Start() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void Update() { if (((ButtonControl)Keyboard.current.insertKey).wasPressedThisFrame && (Object)(object)GameNetworkManager.Instance != (Object)null && GameNetworkManager.Instance.localPlayerController.hasBegunSpectating) { Toggle(); } } private void LateUpdate() { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if (!SpectatingEnemies) { return; } if (SpectatorList.Length == 0) { SpectatingEnemies = false; return; } if (SpectatedEnemyIndex >= SpectatorList.Length) { GetNextValidSpectatable(); return; } Spectatable obj = SpectatorList.ElementAtOrDefault(SpectatedEnemyIndex); if ((Object)(object)obj == (Object)null) { GetNextValidSpectatable(); return; } Vector3? spectatePosition = GetSpectatePosition(obj); if (!spectatePosition.HasValue) { GetNextValidSpectatable(); return; } if (obj.enemyName == "Enemy") { TryFixName(ref obj); } HUDManager.Instance.localPlayer.spectateCameraPivot.position = spectatePosition.Value + GetZoomDistance(obj); ((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = "(Spectating: " + obj.enemyName + ")"; Plugin.raycastSpectate.Invoke(HUDManager.Instance.localPlayer, Array.Empty<object>()); } private Vector3? GetSpectatePosition(Spectatable obj) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (obj.type == SpectatableType.Enemy) { EnemyAI component = ((Component)obj).GetComponent<EnemyAI>(); if ((Object)(object)component != (Object)null) { return ((Object)(object)component.eye == (Object)null) ? ((Component)component).transform.position : component.eye.position; } } else if (obj.type == SpectatableType.Turret) { Turret component2 = ((Component)obj).GetComponent<Turret>(); if ((Object)(object)component2 != (Object)null) { return ((Component)component2.centerPoint).transform.position; } } else { if (obj.type == SpectatableType.Landmine) { return ((Component)obj).transform.position; } Debug.LogError((object)("[SpectateEnemy]: Error when spectating: no handler for SpectatableType " + obj.type)); } return null; } private Vector3 GetZoomDistance(Spectatable obj) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (obj.enemyName == "ForestGiant") { return Vector3.up * 3f; } if (obj.enemyName == "MouthDog" || obj.enemyName == "Jester") { return Vector3.up * 2f; } return Vector3.up; } private void TryFixName(ref Spectatable obj) { EnemyAI val = default(EnemyAI); Turret val2 = default(Turret); Landmine val3 = default(Landmine); if (((Component)obj).gameObject.TryGetComponent<EnemyAI>(ref val)) { obj.enemyName = val.enemyType.enemyName; } else if (((Component)obj).gameObject.TryGetComponent<Turret>(ref val2)) { obj.enemyName = "Turret"; } else if (((Component)obj).gameObject.TryGetComponent<Landmine>(ref val3)) { obj.enemyName = "Landmine"; } } public void ToggleSpectatingMode(PlayerControllerB __instance) { //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) SpectatingEnemies = !SpectatingEnemies; if (SpectatingEnemies) { SpectatorList = Object.FindObjectsByType<Spectatable>((FindObjectsSortMode)0); if (SpectatorList.Length == 0) { SpectatingEnemies = false; Plugin.displaySpectatorTip.Invoke(HUDManager.Instance, new object[1] { "No enemies to spectate" }); return; } if (SpectatedEnemyIndex == -1 || SpectatedEnemyIndex >= SpectatorList.Length) { if ((Object)(object)__instance.spectatedPlayerScript == (Object)null) { GetNextValidSpectatable(); } else { List<Spectatable> list = SpectatorList.Where((Spectatable x) => settings[x.enemyName]).ToList(); if (list.Count == 0) { Plugin.displaySpectatorTip.Invoke(HUDManager.Instance, new object[1] { "No enemies to spectate" }); return; } float num = 999999f; int spectatedEnemyIndex = 0; for (int i = 0; i < list.Count; i++) { Vector3 val = ((Component)list[i]).transform.position - ((Component)__instance.spectatedPlayerScript).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num * num) { num = sqrMagnitude; spectatedEnemyIndex = i; } } SpectatedEnemyIndex = spectatedEnemyIndex; } } else if (!settings[SpectatorList[SpectatedEnemyIndex].enemyName]) { GetNextValidSpectatable(); } __instance.spectatedPlayerScript = null; } else { __instance.spectatedPlayerScript = ((IEnumerable<PlayerControllerB>)__instance.playersManager.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => !x.isPlayerDead)); ((TMP_Text)HUDManager.Instance.spectatingPlayerText).text = "(Spectating: " + __instance.spectatedPlayerScript.playerUsername + ")"; } } public void PopulateSettings(SelectableLevel level) { foreach (SpawnableEnemyWithRarity enemy in level.Enemies) { settings.TryAdd(enemy.enemyType.enemyName, value: true); } foreach (SpawnableEnemyWithRarity outsideEnemy in level.OutsideEnemies) { settings.TryAdd(outsideEnemy.enemyType.enemyName, value: true); } foreach (SpawnableEnemyWithRarity daytimeEnemy in level.DaytimeEnemies) { settings.TryAdd(daytimeEnemy.enemyType.enemyName, value: false); } settings.TryAdd("Landmine", value: false); settings.TryAdd("Turret", value: false); try { if (File.Exists(Paths.ConfigPath + "/SpectateEnemy.cfg")) { string[] array = File.ReadAllLines(Paths.ConfigPath + "/SpectateEnemy.cfg"); if (array[3] == "[Config]") { Debug.LogWarning((object)"[SpectateEnemies]: Config not found, using default values!"); return; } string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(':'); if (array3.Length == 2 && settings.ContainsKey(array3[0]) && bool.TryParse(array3[1], out var result)) { settings[array3[0]] = result; } } Debug.LogWarning((object)"[SpectateEnemies]: Config loaded"); } else { Debug.LogWarning((object)"[SpectateEnemies]: Config not found, using default values!"); } } catch (Exception) { Debug.LogWarning((object)"[SpectateEnemies]: Config failed to load, using default values!"); } } private void OnApplicationQuit() { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair<string, bool> setting in settings) { stringBuilder.Append(setting.Key); stringBuilder.Append(':'); stringBuilder.Append(setting.Value); stringBuilder.AppendLine(); } File.WriteAllText(Paths.ConfigPath + "/SpectateEnemy.cfg", stringBuilder.ToString()); Debug.LogWarning((object)"[SpectateEnemies]: Config saved"); } public bool SpectateNextEnemy() { if (SpectatorList.Length == 0) { SpectatingEnemies = false; return true; } GetNextValidSpectatable(); return false; } private void GetNextValidSpectatable() { int i = 0; int num = SpectatedEnemyIndex; for (; i < SpectatorList.Length; i++) { num++; if (num >= SpectatorList.Length) { num = 0; } if (settings[SpectatorList[num].enemyName]) { SpectatedEnemyIndex = num; return; } } SpectatingEnemies = false; Plugin.displaySpectatorTip.Invoke(HUDManager.Instance, new object[1] { "No enemies to spectate" }); } private void AssertSettings() { foreach (KeyValuePair<string, bool> setting in settings) { Debug.LogWarning((object)$"{setting.Key} : {setting.Value}"); } } public bool GetSetting(string name) { if (settings.ContainsKey(name)) { return settings[name]; } return false; } public void Toggle() { WindowOpen = !WindowOpen; } public void Hide() { WindowOpen = false; } public bool IsMenuOpen() { return WindowOpen; } private void OnGUI() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (WindowOpen) { GUI.color = Color.gray; window = GUI.Window(0, window, new WindowFunction(DrawGUI), "Spectator Settings"); } } private void DrawGUI(int windowID) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (windowID == 0) { GUI.Label(new Rect(10f, 30f, 500f, 100f), "Tip: Checking the box next to an enemy name will enable spectating it."); int num = 0; int num2 = 0; foreach (string item in settings.Keys.ToList()) { settings[item] = GUI.Toggle(new Rect((float)(10 + 150 * num), (float)(60 + 30 * num2), 150f, 20f), settings[item], item); num++; if (num == 3) { num = 0; num2++; } } } GUI.DragWindow(new Rect(0f, 0f, 10000f, 10000f)); } } public class SpectateEnemiesAPI { public static bool IsLoaded => (Object)(object)SpectateEnemies.Instance != (Object)null; public static bool IsSpectatingEnemies => SpectateEnemies.Instance.SpectatingEnemies; public static GameObject CurrentEnemySpectating() { if (IsSpectatingEnemies && SpectateEnemies.Instance.SpectatedEnemyIndex > -1) { return ((Component)SpectateEnemies.Instance.SpectatorList[SpectateEnemies.Instance.SpectatedEnemyIndex]).gameObject; } return null; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "SpectateEnemy"; public const string PLUGIN_NAME = "SpectateEnemy"; public const string PLUGIN_VERSION = "2.0.0"; } } namespace SpectateEnemy.Patches { [HarmonyPatch(typeof(EnemyAI), "Start")] internal class EnemyAI_Patches { private static void Postfix(EnemyAI __instance) { Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>(); spectatable.enemyName = __instance.enemyType.enemyName; } } [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] internal class GameNetworkManager_Patches { private static void Postfix() { SpectateEnemies.Instance.SpectatedEnemyIndex = -1; SpectateEnemies.Instance.SpectatingEnemies = false; SpectateEnemies.Instance.Hide(); } } [HarmonyPatch(typeof(HUDManager), "Update")] internal class HUDManager_Patches { private static void Postfix(HUDManager __instance) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) || !GameNetworkManager.Instance.localPlayerController.hasBegunSpectating) { return; } if (StartOfRound.Instance.shipIsLeaving) { SpectateEnemies.Instance.Hide(); Light component = ((Component)__instance.playersManager.spectateCamera).GetComponent<Light>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } return; } MovementActions movement = __instance.playerActions.Movement; InputBinding val = ((MovementActions)(ref movement)).Interact.bindings[0]; string text = InputControlPath.ToHumanReadableString(((InputBinding)(ref val)).effectivePath, (HumanReadableStringOptions)2, (InputControl)null); TextMeshProUGUI holdButtonToEndGameEarlyText = __instance.holdButtonToEndGameEarlyText; ((TMP_Text)holdButtonToEndGameEarlyText).text = ((TMP_Text)holdButtonToEndGameEarlyText).text + "\n\n\n\n\nSwitch to " + (SpectateEnemies.Instance.SpectatingEnemies ? "Players" : "Enemies") + ": [" + text + "]\nToggle Flashlight : [RMB] (Click)\nConfig Menu : [Insert]"; movement = __instance.playerActions.Movement; if (((MovementActions)(ref movement)).PingScan.WasReleasedThisFrame()) { Light component2 = ((Component)__instance.playersManager.spectateCamera).GetComponent<Light>(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = !((Behaviour)component2).enabled; } } } } [HarmonyPatch(typeof(Landmine), "Start")] internal class Landmine_Patches { private static void Postfix(Landmine __instance) { Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>(); spectatable.type = SpectatableType.Landmine; spectatable.enemyName = "Landmine"; } } [HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")] internal class MaskedPlayerEnemy_Patches { private static void Postfix(MaskedPlayerEnemy __instance) { Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>(); if ((Object)(object)__instance.mimickingPlayer != (Object)null) { spectatable.enemyName = __instance.mimickingPlayer.playerUsername; } else { spectatable.enemyName = ((EnemyAI)__instance).enemyType.enemyName; } } } [HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")] internal class PlayerControllerB_Interact { private static bool Prefix(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && !StartOfRound.Instance.shipIsLeaving && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) { SpectateEnemies.Instance.ToggleSpectatingMode(__instance); return false; } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "ActivateItem_performed")] internal class PlayerControllerB_Use { private static bool Prefix(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && !StartOfRound.Instance.shipIsLeaving && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) { if (SpectateEnemies.Instance.IsMenuOpen()) { return false; } if (SpectateEnemies.Instance.SpectatingEnemies) { SpectateEnemies.Instance.SpectateNextEnemy(); } return true; } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")] internal class PlayerControllerB_SpectateNext { private static bool Prefix() { return !SpectateEnemies.Instance.SpectatingEnemies; } } [HarmonyPatch(typeof(QuickMenuManager), "Start")] internal class QuickMenuManager_Patches { private static void Postfix(QuickMenuManager __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)SpectateEnemies.Instance == (Object)null) { GameObject val = new GameObject("SpectateEnemiesObject"); SpectateEnemies spectateEnemies = val.AddComponent<SpectateEnemies>(); spectateEnemies.PopulateSettings(__instance.testAllEnemiesLevel); } } } [HarmonyPatch(typeof(StartOfRound), "ShipLeave")] internal class StartOfRound_Patches { private static void Postfix() { SpectateEnemies.Instance.SpectatedEnemyIndex = -1; SpectateEnemies.Instance.SpectatingEnemies = false; SpectateEnemies.Instance.Hide(); } } [HarmonyPatch(typeof(Turret), "Start")] internal class Turret_Patches { private static void Postfix(Turret __instance) { Spectatable spectatable = ((Component)__instance).gameObject.AddComponent<Spectatable>(); spectatable.type = SpectatableType.Turret; spectatable.enemyName = "Turret"; } } }
plugins/Symbiosis.dll
Decompiled 2 years agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Symbiosis.Extensions; using Symbiosis.Patches; using Symbiosis.Utils; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Symbiosis")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Symbiosis")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("97f95e36-1154-479c-be65-4ef35b78018f")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace Symbiosis { [BepInPlugin("niceh.Symbiosis", "Symbiosis", "1.0.2")] public class Plugin : BaseUnityPlugin { public const string GUID = "niceh.Symbiosis"; public const string Name = "Symbiosis"; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("niceh.Symbiosis"); val.PatchAll(typeof(Patch_HoarderBugAI)); val.PatchAll(typeof(Patch_ExtensionLadderItem)); val.PatchAll(typeof(Patch_StunGrenadeItem)); } } } namespace Symbiosis.Utils { public static class Util_GrabbableObject { public static HoarderBugAI FindHoarderBug(this GrabbableObject item) { if ((Object)(object)item.playerHeldBy != (Object)null) { return null; } HoarderBugAI[] array = Object.FindObjectsByType<HoarderBugAI>((FindObjectsSortMode)0); foreach (HoarderBugAI val in array) { if (val != null && val.heldItem != null && !((Object)(object)val.heldItem.itemGrabbableObject != (Object)(object)item)) { return val; } } return null; } } } namespace Symbiosis.Extensions { public static class Extension_HoarderBugAI { private static readonly MethodInfo info_DropItem = typeof(HoarderBugAI).GetMethod("DropItem", BindingFlags.Instance | BindingFlags.NonPublic); public static void DropItem(this HoarderBugAI bug, NetworkObject item, Vector3 targetFloorPosition, bool droppingInNest = true) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) info_DropItem?.Invoke(bug, new object[3] { item, targetFloorPosition, droppingInNest }); } } public static class Extension_StunGrenadeItem { public static readonly FieldInfo info_pullPinCoroutine = typeof(StunGrenadeItem).GetField("pullPinCoroutine", BindingFlags.Instance | BindingFlags.NonPublic); public static void SetPullPinCoroutine(this StunGrenadeItem item, Coroutine coroutine) { info_pullPinCoroutine?.SetValue(item, coroutine); } public static Coroutine GetPullPinCoroutine(this StunGrenadeItem item) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return (Coroutine)(info_pullPinCoroutine?.GetValue(item)); } public static IEnumerator NoPlayerPullPinAnimation(this StunGrenadeItem item) { item.inPullingPinAnimation = true; item.itemAnimator.SetTrigger("pullPin"); item.itemAudio.PlayOneShot(item.pullPinSFX); WalkieTalkie.TransmitOneShotAudio(item.itemAudio, item.pullPinSFX, 0.8f); yield return (object)new WaitForSeconds(1f); item.inPullingPinAnimation = false; item.pinPulled = true; ((GrabbableObject)item).itemUsedUp = true; } } } namespace Symbiosis.Patches { internal static class Patch_ExtensionLadderItem { [HarmonyPatch(typeof(ExtensionLadderItem), "ItemActivate")] [HarmonyPrefix] private static bool ItemActivate(ExtensionLadderItem __instance) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)null) { return true; } Plugin.Log.LogInfo((object)"ITEM IS NOT HELD BY PLAYER"); if (!((NetworkBehaviour)__instance).IsOwner) { return true; } Plugin.Log.LogInfo((object)"ITEM IS OWNER"); HoarderBugAI val = ((GrabbableObject)(object)__instance).FindHoarderBug(); if (val == null) { Plugin.Log.LogInfo((object)"NO BUG FOUND"); return false; } Plugin.Log.LogInfo((object)"DROPPING LADDER"); val.DropItem(((Component)__instance).GetComponent<NetworkObject>(), ((GrabbableObject)__instance).GetItemFloorPosition(default(Vector3)), droppingInNest: false); return false; } } internal static class Patch_HoarderBugAI { private static readonly Random _rand = new Random(); [HarmonyPatch(typeof(HoarderBugAI), "Start")] [HarmonyPrefix] private static void Start(HoarderBugAI __instance) { ((MonoBehaviour)__instance).StartCoroutine(HoarderBugUseItem(__instance)); } private static IEnumerator HoarderBugUseItem(HoarderBugAI bug) { while (((Behaviour)bug).isActiveAndEnabled) { try { if (!((EnemyAI)bug).inSpecialAnimation && !((EnemyAI)bug).isEnemyDead && !StartOfRound.Instance.allPlayersDead && bug.heldItem != null && (Object)(object)bug.heldItem.itemGrabbableObject != (Object)null) { ManualLogSource log = Plugin.Log; HoarderBugItem heldItem = bug.heldItem; log.LogInfo((object)("USING " + ((heldItem != null) ? ((Object)heldItem.itemGrabbableObject.itemProperties).name : null))); bug.heldItem.itemGrabbableObject.UseItemOnClient(_rand.Next(3) != 0); } } catch (Exception ex) { Plugin.Log.LogError((object)ex); } yield return (object)new WaitForSeconds((float)_rand.Next(20)); } } } internal static class Patch_StunGrenadeItem { [HarmonyPatch(typeof(StunGrenadeItem), "ItemActivate")] [HarmonyPrefix] private static bool ItemActivate(StunGrenadeItem __instance) { if ((Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)null) { return true; } Plugin.Log.LogInfo((object)"ITEM IS NOT HELD BY PLAYER"); if (__instance.inPullingPinAnimation) { return true; } Plugin.Log.LogInfo((object)"ITEM IS IN PULLING ANIMATION"); if (__instance.GetPullPinCoroutine() != null) { return true; } Plugin.Log.LogInfo((object)"ITEM HAS NO COROUTINE: STARTING NO PLAYER PULLING PIN ANIMATION"); __instance.SetPullPinCoroutine(((MonoBehaviour)__instance).StartCoroutine(__instance.NoPlayerPullPinAnimation())); return false; } } }
plugins/TooManyEmotes.dll
Decompiled 2 years ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Dissonance.Integrations.Unity_NFGO; using GameNetcodeStuff; using HarmonyLib; using MoreCompany.Cosmetics; using TMPro; using TooManyEmotes.Config; using TooManyEmotes.Networking; using TooManyEmotes.Patches; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Animations.Rigging; using UnityEngine.EventSystems; using UnityEngine.Experimental.Rendering; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("TooManyEmotes")] [assembly: AssemblyDescription("Mod made by flipf17")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TooManyEmotes")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d6950625-e3a1-4896-a183-87110491bf18")] [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 TooManyEmotes { [HarmonyPatch] public static class EmoteMenuManager { public static GameObject menuGameObject; public static RectTransform menuTransform; public static CanvasGroup canvasGroup; public static RawImage renderTextureImageUI; public static TextMeshPro swapPageText; public static TextMeshPro currentEmoteText; public static RenderTexture renderTexture; public static Camera renderingCamera; public static GameObject previewPlayerObject; public static SkinnedMeshRenderer previewPlayerMesh; public static Animator previewPlayerAnimator; public static AnimatorOverrideController previewPlayerAnimatorController; public static int playerLayer = LayerMask.NameToLayer("Player"); public static float hoveredAlpha = 0.75f; public static float unhoveredAlpha = 0.75f; public static Color defaultUIColor = new Color(0.3f, 0.3f, 0.3f); public static List<EmoteUIElement> emoteUIElementsList; public static int hoveredEmoteUIIndex = -1; public static int currentPage = 0; public static List<EmoteLoadoutUIElement> emoteLoadoutUIElementsList; public static List<List<UnlockableEmote>> emoteLoadouts; public static Color selectedLoadoutUIColor = new Color(0.2f, 0.2f, 1f); public static int currentLoadoutIndex = -1; public static int numLoadouts = 3; public static int hoveredLoadoutUIIndex = -1; public static QuickMenuManager quickMenuManager => StartOfRound.Instance?.localPlayerController?.quickMenuManager; public static PlayerControllerB localPlayerController => StartOfRound.Instance?.localPlayerController; public static int playerLayerMask => 1 << playerLayer; public static int hoveredEmoteIndex => (hoveredEmoteUIIndex >= 0) ? (hoveredEmoteUIIndex + 8 * currentPage) : (-1); public static int numPages => Mathf.Max((currentLoadoutEmotesList.Count - 1) / emoteUIElementsList.Count, 0) + 1; public static UnlockableEmote previewingEmote => (hoveredEmoteIndex >= 0 && hoveredEmoteIndex < currentLoadoutEmotesList.Count) ? currentLoadoutEmotesList[hoveredEmoteIndex] : null; public static List<UnlockableEmote> currentLoadoutEmotesList => emoteLoadouts[currentLoadoutIndex]; public static bool isMenuOpen => menuGameObject.activeSelf; [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPostfix] public static void InitializeUI(HUDManager __instance) { if (!((Object)(object)Plugin.radialMenuPrefab == (Object)null)) { menuGameObject = Object.Instantiate<GameObject>(Plugin.radialMenuPrefab, __instance.HUDContainer.transform.parent); menuGameObject.transform.SetAsLastSibling(); ((Object)menuGameObject).name = "EmotesRadialMenu"; menuTransform = menuGameObject.GetComponent<RectTransform>(); renderTextureImageUI = menuGameObject.GetComponentInChildren<RawImage>(); Transform transform = ((Component)((Transform)menuTransform).Find("RadialMenuUI/RadialElements")).transform; swapPageText = ((Component)((Transform)menuTransform).Find("RadialMenuUI/RadialBase/SwapPageText")).GetComponent<TextMeshPro>(); currentEmoteText = ((Component)((Transform)menuTransform).Find("RadialMenuUI/RadialBase/CurrentEmoteText")).GetComponent<TextMeshPro>(); ((TMP_Text)currentEmoteText).text = ""; emoteUIElementsList = new List<EmoteUIElement>(); currentPage = 0; hoveredEmoteUIIndex = -1; for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); EmoteUIElement item = new EmoteUIElement { uiGameObject = ((Component)child).gameObject, id = i, backgroundImage = ((Component)child).GetComponentInChildren<Image>(), textContainer = ((Component)child).GetComponentInChildren<TextMeshPro>() }; emoteUIElementsList.Add(item); } EmoteLoadoutUIElement.uiCount = 0; Transform transform2 = ((Component)((Transform)menuTransform).Find("RadialMenuUI/EmoteLoadouts")).transform; ((Component)transform2).gameObject.AddComponent<EmoteLoadoutUIContainer>(); emoteLoadoutUIElementsList = new List<EmoteLoadoutUIElement>(); emoteLoadoutUIElementsList.Add(((Component)transform2.GetChild(0)).gameObject.AddComponent<EmoteLoadoutUIElement>()); emoteLoadoutUIElementsList.Add(Object.Instantiate<EmoteLoadoutUIElement>(emoteLoadoutUIElementsList[0], transform2)); emoteLoadoutUIElementsList.Add(Object.Instantiate<EmoteLoadoutUIElement>(emoteLoadoutUIElementsList[0], transform2)); emoteLoadoutUIElementsList.Add(Object.Instantiate<EmoteLoadoutUIElement>(emoteLoadoutUIElementsList[0], transform2)); emoteLoadoutUIElementsList.Add(Object.Instantiate<EmoteLoadoutUIElement>(emoteLoadoutUIElementsList[0], transform2)); emoteLoadoutUIElementsList.Add(Object.Instantiate<EmoteLoadoutUIElement>(emoteLoadoutUIElementsList[0], transform2)); emoteLoadoutUIElementsList.Add(Object.Instantiate<EmoteLoadoutUIElement>(emoteLoadoutUIElementsList[0], transform2)); for (int j = 0; j < emoteLoadoutUIElementsList.Count; j++) { ((Object)emoteLoadoutUIElementsList[j]).name = "EmoteLoadout_" + j; } emoteLoadoutUIElementsList[0].loadoutName = "Favorites"; emoteLoadoutUIElementsList[1].loadoutName = $"<color={UnlockableEmote.rarityColorCodes[3]}>Legendary</color>"; emoteLoadoutUIElementsList[2].loadoutName = $"<color={UnlockableEmote.rarityColorCodes[2]}>Rare</color>"; emoteLoadoutUIElementsList[3].loadoutName = $"<color={UnlockableEmote.rarityColorCodes[1]}>Uncommon</color>"; emoteLoadoutUIElementsList[4].loadoutName = $"<color={UnlockableEmote.rarityColorCodes[0]}>Common</color>"; emoteLoadoutUIElementsList[5].loadoutName = "Complementary"; emoteLoadoutUIElementsList[6].loadoutName = "All"; SaveManager.LoadFavoritedEmotes(); emoteLoadouts = new List<List<UnlockableEmote>> { StartOfRoundPatcher.unlockedFavoriteEmotes, StartOfRoundPatcher.unlockedEmotesTier3, StartOfRoundPatcher.unlockedEmotesTier2, StartOfRoundPatcher.unlockedEmotesTier1, StartOfRoundPatcher.unlockedEmotesTier0, StartOfRoundPatcher.complementaryEmotes, StartOfRoundPatcher.unlockedEmotes }; if (currentLoadoutIndex < 0 || currentLoadoutIndex >= emoteLoadouts.Count) { currentLoadoutIndex = emoteLoadouts.Count - 1; } InitializeAnimationRenderer(); menuGameObject.SetActive(false); } } [HarmonyPatch(typeof(HUDManager), "Update")] [HarmonyPostfix] public static void GetInput() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)previewPlayerAnimatorController == (Object)null || !isMenuOpen) { return; } if (EmoteLoadoutUIContainer.hovered || hoveredLoadoutUIIndex != -1) { if (hoveredEmoteUIIndex != -1) { OnHoveredNewElement(-1); } return; } Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)(Screen.width / 2), (float)(Screen.height / 2)); Vector2 val3 = val - val2; int num = -1; if (((Vector2)(ref val3)).magnitude / (float)Screen.height >= 0.17f) { float num2 = Mathf.Atan2(val3.y, 0f - val3.x) * 57.29578f - 67.5f; if (num2 < 0f) { num2 += 360f; } num = Mathf.FloorToInt(num2 / 45f); } if (num != hoveredEmoteUIIndex) { OnHoveredNewElement(num); } } public static void OnHoveredNewLoadoutElement(int index) { if (hoveredLoadoutUIIndex == index) { return; } hoveredLoadoutUIIndex = index; foreach (EmoteLoadoutUIElement emoteLoadoutUIElements in emoteLoadoutUIElementsList) { emoteLoadoutUIElements.OnHover(emoteLoadoutUIElements.id == index); } } public static void OnHoveredNewElement(int index) { if (hoveredEmoteUIIndex != -1 && hoveredEmoteUIIndex != index) { emoteUIElementsList[hoveredEmoteUIIndex].OnHover(hovered: false); } if (index != -1) { emoteUIElementsList[index].OnHover(); } hoveredEmoteUIIndex = index; SetPreviewAnimation(hoveredEmoteIndex); } public static void SwapPrevPage() { currentPage--; if (currentPage < 0) { currentPage = numPages - 1; } UpdateEmoteWheel(); } public static void SwapNextPage() { currentPage++; if (currentPage >= numPages) { currentPage = 0; } UpdateEmoteWheel(); } public static void UpdateEmoteWheel() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) currentPage = Mathf.Clamp(currentPage, 0, numPages - 1); ((TMP_Text)swapPageText).text = $"[{currentPage + 1} / {numPages}]\n[Mouse Scroll]"; for (int i = 0; i < emoteLoadoutUIElementsList.Count; i++) { EmoteLoadoutUIElement emoteLoadoutUIElement = emoteLoadoutUIElementsList[i]; emoteLoadoutUIElement.OnHover(hoveredLoadoutUIIndex == emoteLoadoutUIElement.id); } for (int j = 0; j < emoteUIElementsList.Count; j++) { EmoteUIElement emoteUIElement = emoteUIElementsList[j]; int num = j + 8 * currentPage; ((TMP_Text)emoteUIElement.textContainer).text = ""; emoteUIElement.emote = null; Color baseColor = defaultUIColor; if (num < currentLoadoutEmotesList.Count) { UnlockableEmote unlockableEmote = currentLoadoutEmotesList[num]; if (unlockableEmote != null) { emoteUIElement.emote = unlockableEmote; ((TMP_Text)emoteUIElement.textContainer).text = unlockableEmote.displayName; } } emoteUIElement.baseColor = baseColor; emoteUIElement.OnHover(hovered: false); } if (hoveredEmoteUIIndex >= 0 && hoveredEmoteUIIndex < 8) { OnHoveredNewElement(hoveredEmoteUIIndex); } } public static void SetPreviewAnimation(int emoteIndex) { if (emoteIndex >= 0 && emoteIndex < currentLoadoutEmotesList.Count && currentLoadoutEmotesList[emoteIndex] != null) { UnlockableEmote unlockableEmote = currentLoadoutEmotesList[emoteIndex]; previewPlayerObject.SetActive(true); ((Behaviour)renderingCamera).enabled = true; previewPlayerAnimatorController["EmoteStart"] = unlockableEmote.animationClip; previewPlayerAnimatorController["EmoteLoop"] = (((Object)(object)unlockableEmote.transitionsToClip != (Object)null) ? unlockableEmote.transitionsToClip : null); previewPlayerAnimator.SetBool("hasTransition", (Object)(object)unlockableEmote.transitionsToClip != (Object)null); previewPlayerAnimator.Play("EmoteStart", 0, 0f); ((TMP_Text)currentEmoteText).text = "[" + unlockableEmote.displayNameColorCoded + "]\n[MMB] " + (StartOfRoundPatcher.allFavoriteEmotes.Contains(unlockableEmote.emoteName) ? "Unfavorite" : "Favorite"); } else { previewPlayerAnimatorController["EmoteStart"] = null; previewPlayerAnimatorController["EmoteLoop"] = null; previewPlayerObject.SetActive(false); ((TMP_Text)currentEmoteText).text = ""; DisableRenderCameraNextFrame(); } } public static void DisableRenderCameraNextFrame() { ((MonoBehaviour)HUDManager.Instance).StartCoroutine(DisableRenderCameraNextFrameCoroutine()); static IEnumerator DisableRenderCameraNextFrameCoroutine() { yield return null; ((Behaviour)renderingCamera).enabled = false; } } public static void SetCurrentEmoteLoadout(int loadoutIndex) { if (currentLoadoutIndex != loadoutIndex) { currentPage = 0; currentLoadoutIndex = loadoutIndex; UpdateEmoteWheel(); } } public static void ToggleFavoriteHoveredEmote() { if (isMenuOpen && previewingEmote != null) { string emoteName = previewingEmote.emoteName; if (StartOfRoundPatcher.allFavoriteEmotes.Contains(emoteName)) { StartOfRoundPatcher.allFavoriteEmotes.Remove(emoteName); } else { StartOfRoundPatcher.allFavoriteEmotes.Add(emoteName); } StartOfRoundPatcher.UpdateUnlockedFavoriteEmotes(); SaveManager.SaveFavoritedEmotes(); UpdateEmoteWheel(); } } public static void ToggleEmoteMenu() { if (!isMenuOpen) { OpenEmoteMenu(); } else { CloseEmoteMenu(); } } public static void OpenEmoteMenu() { menuGameObject.SetActive(true); Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; quickMenuManager.isMenuOpen = true; ((Renderer)previewPlayerMesh).material = ((Renderer)localPlayerController.thisPlayerModel).material; UpdateEmoteWheel(); } public static void CloseEmoteMenu() { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; localPlayerController.isFreeCamera = false; menuGameObject.SetActive(false); quickMenuManager.CloseQuickMenu(); } public static bool CanOpenEmoteMenu() { if ((quickMenuManager.isMenuOpen && !isMenuOpen) || (Object)(object)previewPlayerObject == (Object)null) { return false; } if (localPlayerController.isPlayerDead || localPlayerController.inTerminalMenu || localPlayerController.isTypingChat || localPlayerController.isPlayerDead || localPlayerController.inSpecialInteractAnimation || localPlayerController.isGrabbingObjectAnimation || localPlayerController.inShockingMinigame || localPlayerController.isClimbingLadder || localPlayerController.isSinking || (Object)(object)localPlayerController.inAnimationWithEnemy != (Object)null) { return false; } return true; } private static void InitializeAnimationRenderer() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) renderingCamera = new GameObject("AnimationRenderingCamera").AddComponent<Camera>(); Object.Destroy((Object)(object)((Component)renderingCamera).GetComponent<AudioListener>()); renderingCamera.cullingMask = playerLayerMask; renderingCamera.clearFlags = (CameraClearFlags)2; renderingCamera.cameraType = (CameraType)4; renderingCamera.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0f); renderingCamera.allowHDR = false; renderingCamera.allowMSAA = false; renderingCamera.farClipPlane = 5f; renderTexture = new RenderTexture(1024, 1024, 24); renderTexture.format = (RenderTextureFormat)0; renderTexture.graphicsFormat = (GraphicsFormat)8; renderTexture.depthStencilFormat = (GraphicsFormat)92; renderingCamera.targetTexture = renderTexture; ((Component)renderingCamera).transform.position = Vector3.down * 1000f; renderTextureImageUI.texture = (Texture)(object)renderTexture; Light val = new GameObject("Spotlight").AddComponent<Light>(); val.type = (LightType)0; ((Component)val).transform.position = ((Component)renderingCamera).transform.position; ((Component)val).transform.parent = ((Component)renderingCamera).transform; ((Component)val).transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); val.intensity = 50f; val.range = 40f; val.innerSpotAngle = 100f; val.spotAngle = 120f; ((Component)val).gameObject.layer = playerLayer; DisableRenderCameraNextFrame(); } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void InitializePlayerCloneRenderObject(PlayerControllerB __instance) { if (!((Object)(object)Plugin.radialMenuPrefab == (Object)null)) { ((MonoBehaviour)__instance).StartCoroutine(InitPlayerCloneAfterSpawnAnimation()); } IEnumerator InitPlayerCloneAfterSpawnAnimation() { yield return (object)new WaitForSeconds(2f); previewPlayerObject = Object.Instantiate<GameObject>(((Component)__instance).gameObject, ((Component)renderingCamera).transform); ((Object)previewPlayerObject).name = "PreviewPlayerAnimationObject"; GameObject modelGameObject = ((Component)previewPlayerObject.transform.Find("ScavengerModel")).gameObject; GameObject metarigGameObject = ((Component)modelGameObject.transform.Find("metarig")).gameObject; PlayerControllerB copyPlayerController = previewPlayerObject.GetComponentInChildren<PlayerControllerB>(); ((Renderer)copyPlayerController.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)1; previewPlayerMesh = copyPlayerController.thisPlayerModel; Object.Destroy((Object)(object)modelGameObject.GetComponentInChildren<LODGroup>()); Object.DestroyImmediate((Object)(object)metarigGameObject.GetComponentInChildren<RigBuilder>()); Object.DestroyImmediate((Object)(object)copyPlayerController.playerBodyAnimator); previewPlayerAnimator = metarigGameObject.AddComponent<Animator>(); previewPlayerAnimatorController = new AnimatorOverrideController(Plugin.previewAnimatorController); previewPlayerAnimator.runtimeAnimatorController = (RuntimeAnimatorController)(object)previewPlayerAnimatorController; previewPlayerAnimator.Play("EmoteStart", 0, 0f); Object.Destroy((Object)(object)previewPlayerObject.GetComponent<NfgoPlayer>()); foreach (Transform item in previewPlayerObject.transform) { Transform child3 = item; if (((Object)child3).name != "ScavengerModel") { Object.Destroy((Object)(object)((Component)child3).gameObject); } } foreach (Transform item2 in modelGameObject.transform) { Transform child2 = item2; if (((Object)child2).name != "LOD1" && ((Object)child2).name != "metarig") { Object.Destroy((Object)(object)((Component)child2).gameObject); } } foreach (Transform item3 in metarigGameObject.transform) { Transform child = item3; if (((Object)child).name != "spine") { Object.Destroy((Object)(object)((Component)child).gameObject); } } previewPlayerObject.transform.position = ((Component)renderingCamera).transform.position + ((Component)renderingCamera).transform.forward * 2.8f + Vector3.down * 1.35f; previewPlayerObject.transform.LookAt(new Vector3(((Component)renderingCamera).transform.position.x, previewPlayerObject.transform.position.y, ((Component)renderingCamera).transform.position.z)); SetObjectLayerRecursive(previewPlayerObject, playerLayer); MonoBehaviour[] components = previewPlayerObject.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour script in components) { Object.Destroy((Object)(object)script); } } } private static void SetObjectLayerRecursive(GameObject obj, int layer) { if (!((Object)(object)obj == (Object)null)) { obj.layer = layer; for (int i = 0; i < obj.transform.childCount; i++) { Transform child = obj.transform.GetChild(i); SetObjectLayerRecursive((child != null) ? ((Component)child).gameObject : null, layer); } } } [HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")] [HarmonyPrefix] public static bool OnScrollMouse(CallbackContext context, PlayerControllerB __instance) { if (!isMenuOpen || (Object)(object)__instance != (Object)(object)localPlayerController || !((CallbackContext)(ref context)).performed) { return true; } if (((CallbackContext)(ref context)).ReadValue<float>() < 0f && !ConfigSettings.reverseEmoteWheelScrollDirection.Value) { SwapPrevPage(); } else { SwapNextPage(); } return false; } [HarmonyPatch(typeof(PlayerControllerB), "ItemSecondaryUse_performed")] [HarmonyPrefix] public static bool PreventItemSecondaryUseInMenu(CallbackContext context) { return !isMenuOpen; } [HarmonyPatch(typeof(PlayerControllerB), "ItemTertiaryUse_performed")] [HarmonyPrefix] public static bool PreventItemTertiaryUseInMenu(CallbackContext context) { return !isMenuOpen; } [HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")] [HarmonyPrefix] public static bool PreventInteractInMenu(CallbackContext context) { return !isMenuOpen; } [HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")] [HarmonyPrefix] public static bool OnOpenQuickMenu() { if (isMenuOpen) { CloseEmoteMenu(); return false; } return true; } [HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")] [HarmonyPostfix] public static void OnCloseQuickMenu() { if (isMenuOpen) { CloseEmoteMenu(); } } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPostfix] public static void OnLocalPlayerDeath(Vector3 bodyVelocity, PlayerControllerB __instance) { if ((Object)(object)__instance == (Object)(object)localPlayerController && isMenuOpen && __instance.isPlayerDead) { CloseEmoteMenu(); } } } public class EmoteUIElement { public GameObject uiGameObject; public int id; public Image backgroundImage; public TextMeshPro textContainer; public Color baseColor; public UnlockableEmote emote; public void OnHover(bool hovered = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Color color = baseColor * (hovered ? 1f : 0.5f); color.a = (hovered ? EmoteMenuManager.hoveredAlpha : EmoteMenuManager.unhoveredAlpha); ((Graphic)backgroundImage).color = color; } } public class EmoteLoadoutUIElement : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public static int uiCount; public int id; public string loadoutName; public Image backgroundImage; public TextMeshPro textContainer; private void Awake() { id = uiCount++; backgroundImage = ((Component)this).GetComponentInChildren<Image>(); textContainer = ((Component)this).GetComponentInChildren<TextMeshPro>(); } private void Start() { ((TMP_Text)textContainer).text = loadoutName; } public void OnHover(bool hovered = true) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Color color = ((EmoteMenuManager.currentLoadoutIndex == id) ? EmoteMenuManager.selectedLoadoutUIColor : EmoteMenuManager.defaultUIColor) * (hovered ? 1f : 0.5f); color.a = (hovered ? EmoteMenuManager.hoveredAlpha : EmoteMenuManager.unhoveredAlpha); ((Graphic)backgroundImage).color = color; } public void OnPointerEnter(PointerEventData eventData) { EmoteMenuManager.OnHoveredNewLoadoutElement(id); OnHover(); } public void OnPointerExit(PointerEventData eventData) { EmoteMenuManager.OnHoveredNewLoadoutElement(-1); OnHover(hovered: false); } } public class EmoteLoadoutUIContainer : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public static bool hovered; public void OnPointerEnter(PointerEventData eventData) { hovered = true; } public void OnPointerExit(PointerEventData eventData) { hovered = false; } } public class UnlockableEmote { public int emoteId; public string emoteName; public string randomEmotePoolName = ""; public string displayName = ""; public bool purchasable = true; public AnimationClip animationClip; public AnimationClip transitionsToClip = null; public List<UnlockableEmote> randomEmotePool; public bool complementary = false; public bool isPose = false; public bool canSyncEmote = false; public bool favorite = false; public int rarity = 0; public static string[] rarityColorCodes = new string[4] { ConfigSettings.emoteNameColorTier0.Value, ConfigSettings.emoteNameColorTier1.Value, ConfigSettings.emoteNameColorTier2.Value, ConfigSettings.emoteNameColorTier3.Value }; public string displayNameColorCoded => $"<color={nameColor}>{displayName}</color>"; public string rarityText { get { if (rarity == 0) { return "Common"; } if (rarity == 1) { return "Uncommon"; } if (rarity == 2) { return "Rare"; } if (rarity == 3) { return "Legendary"; } return "Invalid"; } } public int price { get { int num = -1; if (complementary) { num = 0; } else if (rarity == 0) { num = ConfigSync.instance.syncBasePriceEmoteTier0; } else if (rarity == 1) { num = ConfigSync.instance.syncBasePriceEmoteTier1; } else if (rarity == 2) { num = ConfigSync.instance.syncBasePriceEmoteTier2; } else if (rarity == 3) { num = ConfigSync.instance.syncBasePriceEmoteTier3; } return (int)Mathf.Max((float)num * ConfigSync.instance.syncPriceMultiplierEmotesStore, 0f); } } public string nameColor => rarityColorCodes[rarity]; } [HarmonyPatch] public static class Keybinds { private static InputAction OpenEmoteMenuAction; private static InputAction SelectEmoteUIAction; private static InputAction NextEmotePageAction; private static InputAction PrevEmotePageAction; private static InputAction FavoriteEmoteAction; private static InputAction RotatePlayerEmoteAction; public static InputAction RawScrollAction; public static bool holdingRotatePlayerModifier; public static PlayerControllerB localPlayerController => StartOfRound.Instance?.localPlayerController; [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void InitializeHotkeys(PlayerControllerB __instance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown Plugin.Log("Initializing custom emote hotkeys."); OpenEmoteMenuAction = new InputAction((string)null, (InputActionType)0, ConfigSettings.openEmoteMenuKeybind.Value, "Press", (string)null, (string)null); SelectEmoteUIAction = new InputAction((string)null, (InputActionType)0, "<Mouse>/leftButton", "Press", (string)null, (string)null); PrevEmotePageAction = new InputAction((string)null, (InputActionType)0, "<Keyboard>/q", "Press", (string)null, (string)null); NextEmotePageAction = new InputAction((string)null, (InputActionType)0, "<Keyboard>/e", "Press", (string)null, (string)null); FavoriteEmoteAction = new InputAction((string)null, (InputActionType)0, "<Mouse>/middleButton", "Press", (string)null, (string)null); RotatePlayerEmoteAction = new InputAction((string)null, (InputActionType)0, ConfigSettings.rotateCharacterInEmoteKeybind.Value, "Press", (string)null, (string)null); RawScrollAction = new InputAction("Scroll", (InputActionType)0, "<Mouse>/scroll", (string)null, (string)null, (string)null); if (((Component)__instance).gameObject.activeSelf) { SubscribeToEvents(); } } private static void SubscribeToEvents() { Plugin.Log("Subscribing to OnPressCustomEmoteKey events"); OpenEmoteMenuAction.performed += OnPressOpenEmoteMenu; OpenEmoteMenuAction.canceled += OnPressOpenEmoteMenu; SelectEmoteUIAction.performed += OnSelectEmoteUI; PrevEmotePageAction.performed += OnSwapPrevEmotePage; NextEmotePageAction.performed += OnSwapNextEmotePage; FavoriteEmoteAction.performed += OnFavoriteEmote; RotatePlayerEmoteAction.performed += OnUpdateRotatePlayerEmoteModifier; RotatePlayerEmoteAction.canceled += OnUpdateRotatePlayerEmoteModifier; OpenEmoteMenuAction.Enable(); SelectEmoteUIAction.Enable(); PrevEmotePageAction.Enable(); NextEmotePageAction.Enable(); FavoriteEmoteAction.Enable(); RotatePlayerEmoteAction.Enable(); RawScrollAction.Enable(); } [HarmonyPatch(typeof(PlayerControllerB), "OnEnable")] [HarmonyPostfix] public static void OnEnable(PlayerControllerB __instance) { if (!((Object)(object)__instance != (Object)(object)localPlayerController)) { SubscribeToEvents(); } } [HarmonyPatch(typeof(PlayerControllerB), "OnDisable")] [HarmonyPostfix] public static void OnDisable(PlayerControllerB __instance) { if (!((Object)(object)__instance != (Object)(object)localPlayerController)) { Plugin.Log("Unsubscribing from OnPressCustomEmoteKey events."); OpenEmoteMenuAction.performed -= OnPressOpenEmoteMenu; OpenEmoteMenuAction.canceled -= OnPressOpenEmoteMenu; SelectEmoteUIAction.performed -= OnSelectEmoteUI; PrevEmotePageAction.performed -= OnSwapPrevEmotePage; NextEmotePageAction.performed -= OnSwapNextEmotePage; FavoriteEmoteAction.performed -= OnFavoriteEmote; RotatePlayerEmoteAction.performed -= OnUpdateRotatePlayerEmoteModifier; RotatePlayerEmoteAction.canceled -= OnUpdateRotatePlayerEmoteModifier; OpenEmoteMenuAction.Disable(); SelectEmoteUIAction.Disable(); PrevEmotePageAction.Disable(); NextEmotePageAction.Disable(); FavoriteEmoteAction.Disable(); RotatePlayerEmoteAction.Disable(); RawScrollAction.Disable(); } } private static void OnPressOpenEmoteMenu(CallbackContext context) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)localPlayerController == (Object)null || ConfigSettings.disableEmotesForSelf.Value) { return; } if (!EmoteMenuManager.isMenuOpen) { if (((CallbackContext)(ref context)).performed && EmoteMenuManager.CanOpenEmoteMenu()) { EmoteMenuManager.OpenEmoteMenu(); } } else if (ConfigSettings.toggleEmoteMenu.Value) { if (((CallbackContext)(ref context)).performed) { EmoteMenuManager.CloseEmoteMenu(); } } else if (((CallbackContext)(ref context)).canceled) { if (EmoteMenuManager.hoveredEmoteIndex != -1) { PerformEmoteLocal(context); } EmoteMenuManager.CloseEmoteMenu(); } } private static void OnSelectEmoteUI(CallbackContext context) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && EmoteMenuManager.isMenuOpen) { if (EmoteMenuManager.hoveredLoadoutUIIndex != -1 && EmoteMenuManager.hoveredLoadoutUIIndex != EmoteMenuManager.currentLoadoutIndex) { EmoteMenuManager.SetCurrentEmoteLoadout(EmoteMenuManager.hoveredLoadoutUIIndex); } else if (EmoteMenuManager.hoveredEmoteIndex >= 0 && EmoteMenuManager.hoveredEmoteIndex < EmoteMenuManager.currentLoadoutEmotesList.Count) { PerformEmoteLocal(context); EmoteMenuManager.CloseEmoteMenu(); } } } private static void OnSwapPrevEmotePage(CallbackContext context) { if (!((Object)(object)localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && EmoteMenuManager.isMenuOpen && EmoteMenuManager.numPages > 1) { EmoteMenuManager.SwapPrevPage(); } } private static void OnSwapNextEmotePage(CallbackContext context) { if (!((Object)(object)localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && EmoteMenuManager.isMenuOpen && EmoteMenuManager.numPages > 1) { EmoteMenuManager.SwapNextPage(); } } public static void PerformEmoteLocal(CallbackContext context) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (EmoteMenuManager.hoveredEmoteIndex >= 0 && EmoteMenuManager.hoveredEmoteIndex < EmoteMenuManager.currentLoadoutEmotesList.Count && !ConfigSettings.disableEmotesForSelf.Value) { UnlockableEmote unlockableEmote = EmoteMenuManager.currentLoadoutEmotesList[EmoteMenuManager.hoveredEmoteIndex]; if (unlockableEmote != null) { localPlayerController.PerformEmote(context, -(unlockableEmote.emoteId + 1)); } } } public static void OnFavoriteEmote(CallbackContext context) { if (!((Object)(object)localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && EmoteMenuManager.isMenuOpen && EmoteMenuManager.hoveredEmoteUIIndex != -1 && EmoteMenuManager.previewingEmote != null) { EmoteMenuManager.ToggleFavoriteHoveredEmote(); } } public static void OnUpdateRotatePlayerEmoteModifier(CallbackContext context) { if (!((Object)(object)localPlayerController == (Object)null) && !ConfigSettings.disableEmotesForSelf.Value) { if (((CallbackContext)(ref context)).performed) { holdingRotatePlayerModifier = true; } else if (((CallbackContext)(ref context)).canceled) { holdingRotatePlayerModifier = false; } } } } [BepInPlugin("FlipMods.TooManyEmotes", "TooManyEmotes", "1.7.3")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; public static Plugin instance; public static List<AnimationClip> customAnimationClips; public static Dictionary<string, AnimationClip> customAnimationClipsLoopDict = new Dictionary<string, AnimationClip>(); public static List<AnimationClip> complementaryAnimationClips; public static List<AnimationClip> animationClipsTier0; public static List<AnimationClip> animationClipsTier1; public static List<AnimationClip> animationClipsTier2; public static List<AnimationClip> animationClipsTier3; public static AnimationClip idleClip; public static GameObject radialMenuPrefab; public static RuntimeAnimatorController previewAnimatorController; public static Dictionary<string, AudioClip> musicClips; private void Awake() { //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown instance = this; ConfigSettings.BindConfigSettings(); customAnimationClips = new List<AnimationClip>(); customAnimationClipsLoopDict = new Dictionary<string, AnimationClip>(); complementaryAnimationClips = new List<AnimationClip>(LoadEmoteAssetBundle("Assets/emotes_complementary")); animationClipsTier0 = new List<AnimationClip>(LoadEmoteAssetBundle("Assets/emotes_0")); animationClipsTier1 = new List<AnimationClip>(LoadEmoteAssetBundle("Assets/emotes_1")); animationClipsTier2 = new List<AnimationClip>(LoadEmoteAssetBundle("Assets/emotes_2")); animationClipsTier3 = new List<AnimationClip>(LoadEmoteAssetBundle("Assets/emotes_3")); AnimationClip[] array = LoadEmoteAssetBundle("Assets/emotes_misc"); if (array != null && array.Length >= 1) { AnimationClip[] array2 = array; foreach (AnimationClip val in array2) { if (((Object)val).name.Contains("idle")) { idleClip = val; } } } customAnimationClips.AddRange(complementaryAnimationClips); customAnimationClips.AddRange(animationClipsTier0); customAnimationClips.AddRange(animationClipsTier1); customAnimationClips.AddRange(animationClipsTier2); customAnimationClips.AddRange(animationClipsTier3); foreach (AnimationClip customAnimationClip in customAnimationClips) { if (((Object)customAnimationClip).name.StartsWith("fn_")) { ((Object)customAnimationClip).name = ((Object)customAnimationClip).name.Replace("fn_", ""); } if (((Object)customAnimationClip).name.EndsWith("_loop")) { customAnimationClipsLoopDict.Add(((Object)customAnimationClip).name, customAnimationClip); } } foreach (AnimationClip value in customAnimationClipsLoopDict.Values) { customAnimationClips.Remove(value); } LoadRadialMenuAsset(); _harmony = new Harmony("TooManyEmotes"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"TooManyEmotes loaded"); } public static bool IsModLoaded(string guid) { return Chainloader.PluginInfos.ContainsKey(guid); } private static AnimationClip[] LoadEmoteAssetBundle(string assetBundleName) { try { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)instance).Info.Location), assetBundleName); AssetBundle val = AssetBundle.LoadFromFile(text); AnimationClip[] array = val.LoadAllAssets<AnimationClip>(); Log($"Successfully loaded {array.Length} animation clips from asset bundle: {assetBundleName}"); return array; } catch { LogError("Failed to load emotes asset bundle: " + assetBundleName + "."); return (AnimationClip[])(object)new AnimationClip[0]; } } public static void LoadRadialMenuAsset() { try { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)instance).Info.Location), "Assets/radial_menu"); AssetBundle val = AssetBundle.LoadFromFile(text); radialMenuPrefab = val.LoadAsset<GameObject>("RadialMenu"); previewAnimatorController = val.LoadAsset<RuntimeAnimatorController>("PreviewAnimatorController"); Log("Successfully loaded radial menu asset."); } catch { LogError("Failed to load radial menu asset."); } } public static void Log(string message) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } public static void LogWarning(string message) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)message); } public static void LogError(string message) { ((BaseUnityPlugin)instance).Logger.LogError((object)message); } } public static class PluginInfo { public const string PLUGIN_GUID = "FlipMods.TooManyEmotes"; public const string PLUGIN_NAME = "TooManyEmotes"; public const string PLUGIN_VERSION = "1.7.3"; } } namespace TooManyEmotes.Config { public static class ConfigSettings { public static ConfigEntry<bool> unlockEverything; public static ConfigEntry<bool> shareEverything; public static ConfigEntry<bool> syncUnsharedEmotes; public static ConfigEntry<bool> disableRaritySystem; public static ConfigEntry<int> basePriceEmoteRaritySystemDisabled; public static ConfigEntry<int> startingEmoteCredits; public static ConfigEntry<float> addEmoteCreditsMultiplier; public static ConfigEntry<bool> purchaseEmotesWithDefaultCurrency; public static ConfigEntry<float> priceMultiplierEmotesStore; public static ConfigEntry<int> basePriceEmoteTier0; public static ConfigEntry<int> basePriceEmoteTier1; public static ConfigEntry<int> basePriceEmoteTier2; public static ConfigEntry<int> basePriceEmoteTier3; public static ConfigEntry<int> numEmotesStoreRotation; public static ConfigEntry<float> rotationChanceEmoteTier0; public static ConfigEntry<float> rotationChanceEmoteTier1; public static ConfigEntry<float> rotationChanceEmoteTier2; public static ConfigEntry<float> rotationChanceEmoteTier3; public static ConfigEntry<bool> enableMaskedEnemiesEmoting; public static ConfigEntry<float> maskedEnemiesEmoteChanceOnEncounter; public static ConfigEntry<bool> maskedEnemiesAlwaysEmoteOnFirstEncounter; public static ConfigEntry<bool> enableSyncingEmotesWithMaskedEnemies; public static ConfigEntry<bool> overrideStopAndStareDuration; public static ConfigEntry<string> maskedEnemyEmoteRandomDelay; public static ConfigEntry<string> maskedEnemyEmoteRandomDuration; public static ConfigEntry<bool> disableEmotesForSelf; public static ConfigEntry<string> openEmoteMenuKeybind; public static ConfigEntry<string> rotateCharacterInEmoteKeybind; public static ConfigEntry<bool> toggleEmoteMenu; public static ConfigEntry<bool> reverseEmoteWheelScrollDirection; public static ConfigEntry<string> emoteNameColorTier0; public static ConfigEntry<string> emoteNameColorTier1; public static ConfigEntry<string> emoteNameColorTier2; public static ConfigEntry<string> emoteNameColorTier3; public static Dictionary<string, ConfigEntryBase> currentConfigEntries = new Dictionary<string, ConfigEntryBase>(); public static void BindConfigSettings() { Plugin.Log("BindingConfigs"); unlockEverything = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Emote Settings", "I am a Party Pooper", false, "[Host only] If true, every emote will be unlocked in your emote wheel at the start of the game. Also, you're not really a party pooper."); shareEverything = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Emote Settings", "ShareEverything", true, "[Host only] If set to false, emotes in the store will be different for each player. Unlocking emotes will only unlock for the player that purchased the emote. Each player will have their own emote credits. The amount of emote credits that each player will receive will NOT be reduced."); syncUnsharedEmotes = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Emote Settings", "CanSyncUnsharedEmotes", true, "[Host only] Only applies if ShareEverything is false. If set to true, players will be able to sync emotes with other players, even if they do not have the emote being performed unlocked."); disableRaritySystem = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Emote Settings", "DisableRaritySystem", false, "[Host only] If true, every emote will have the same likelyhood of appearing in the emote store."); basePriceEmoteRaritySystemDisabled = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Emote Settings", "BasePriceEmote - Rarity System Disabled", 100, "[Host only] Base price of emotes if the rarity system is disabled."); startingEmoteCredits = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Emote Settings", "StartingEmoteCredits", 100, "[Host only] The number of emote credits you start each game with."); addEmoteCreditsMultiplier = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Emote Settings", "AddEmoteCreditsMultiplier", 0.5f, "[Host only] You gain emote credits based off this multiplier of normal group credits earned. Example: If set to the default, 0.5, and you earn 200 group credits, you will also gain 100 emote credits."); purchaseEmotesWithDefaultCurrency = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Emote Settings", "PurchaseEmotesWithDefaultCredits", true, "[Host only] Setting this to true will allow you to purchase emotes with normal group credits once you run out of emote credits. This setting will automatically be disabled if ShareEverything is false."); priceMultiplierEmotesStore = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Emote Settings", "PriceMultiplierEmotesStore", 1f, "[Host only] Price multiplier for emotes in the store. Only applies if UnlockEverythingAtStart is false."); basePriceEmoteTier0 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Emote Settings", "PriceCommonEmote", 50, "[Host only] The base price of [common]emotes in the store."); basePriceEmoteTier1 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Emote Settings", "PriceUncommonEmote", 100, "[Host only] The base price of [uncommon] emotes in the store."); basePriceEmoteTier2 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Emote Settings", "PriceRareEmote", 200, "[Host only] The base price of [rare] emotes in the store."); basePriceEmoteTier3 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Emote Settings", "PriceLegendaryEmote", 300, "[Host only] The base price of [legendary] emotes in the store."); numEmotesStoreRotation = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Emote Settings", "EmotesInStoreRotation", 6, "[Host only] The number of emotes that will be available at a time in the store. Only applies if UnlockEverythingAtStart is false."); rotationChanceEmoteTier0 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Emote Settings", "RotationWeightCommonEmote", 0.55f, "[Host only] The likelyhood of [common] emotes appearing (per slot) in the store rotation."); rotationChanceEmoteTier1 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Emote Settings", "RotationWeightUncommonEmote", 0.35f, "[Host only] The likelyhood of [uncommon] emotes appearing (per slot) in the store rotation."); rotationChanceEmoteTier2 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Emote Settings", "RotationWeightRareEmote", 0.08f, "[Host only] The likelyhood of [rare] emotes appearing (per slot) in the store rotation."); rotationChanceEmoteTier3 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Emote Settings", "RotationWeightLegendaryEmote", 0.02f, "[Host only] The likelyhood of [legendary] emotes appearing (per slot) in the store rotation."); enableMaskedEnemiesEmoting = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("MaskedEnemyEmotes - Beta", "EnableMaskedEnemiesEmoting", true, "[Host only] Enabling this alone does not change the behaviour of the Masked Enemies, and shouldn't conflict with other mods."); maskedEnemiesEmoteChanceOnEncounter = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("MaskedEnemyEmotes - Beta", "EmoteChanceOnEncounter", 0.25f, "[Host only] Chance per encounter with a Masked Enemy, for them to perform an emote. Use values between 0 and 1."); maskedEnemiesAlwaysEmoteOnFirstEncounter = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("MaskedEnemyEmotes - Beta", "AlwaysEmoteOnFirstEncounter", true, "[Host only] This will force the first encounter (for each player) with a Masked Enemy to trigger an emote, regardless of EmoteChanceOnEncounter."); enableSyncingEmotesWithMaskedEnemies = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("MaskedEnemyEmotes - Beta", "EnableSyncingEmotesWithMaskedEnemies", true, "[Client-side] Enabling this will allow you to sync emotes with Masked Enemies. This config is mainly here to disable in case of strange issues."); maskedEnemyEmoteRandomDelay = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("MaskedEnemyEmotes - Beta", "RandomEmoteDelay", "1.5,2.0", "[Host only] Random range at which Masked Enemies will delay before performing an emote. These values could be raised a bit if OverrideStopAndStareDuration is enabled, otherwise, you may run into emotes ending quickly."); overrideStopAndStareDuration = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("MaskedEnemyEmotes - Beta", "OverrideStopAndStareDuration", true, "[Host only] Enabling this will allow this mod to extend the stop and stare duration for longer emotes. If disabled, emotes may end very quickly. Disable this setting if you run into mod conflicts."); maskedEnemyEmoteRandomDuration = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("MaskedEnemyEmotes - Beta", "RandomEmoteDuration", "2.0,4.0", "[Host only] Random range on how long Masked Enemies will emote for. This will extend the Masked Enemies' stop and stare duration by this amount. Only applies if OverrideStopAndStareDuration is true."); disableEmotesForSelf = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Emote Radial Menu", "DisableEmotingForSelf", false, "Disabling this will not convert your player's animator controller to an AnimatorOverrideController, and you will not be able to perform custom emotes. Disable this in case of specific mod conflicts. You will still be able to see other players emoting."); openEmoteMenuKeybind = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Emote Radial Menu", "OpenEmoteMenuKeybind", "<Keyboard>/backquote", "Keybind for opening the emote radial menu."); rotateCharacterInEmoteKeybind = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Emote Radial Menu", "RotateCharacterInEmoteKeybind", "<Keyboard>/leftAlt", "Keybind to hold to rotate character while performing a custom emote."); toggleEmoteMenu = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Emote Radial Menu", "ToggleEmoteMenu", true, "If set to false, the emote menu will open upon pressing the related keybind, and close upon releasing, and will play the currently hovered emote."); reverseEmoteWheelScrollDirection = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Emote Radial Menu", "ReverseEmoteWheelScrollDirection", false, "Reverses the page swapping direction in your emote when scrolling."); emoteNameColorTier0 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Accessibility", "CommonEmoteNameColor", "#00FF00", "The color of the [common] emote name in the terminal."); emoteNameColorTier1 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Accessibility", "UncommonEmoteNameColor", "#2828FF", "The color of the [uncommon] emote name in the terminal."); emoteNameColorTier2 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Accessibility", "RareEmoteNameColor", "#AA00EE", "The color of the [rare] emote name in the terminal."); emoteNameColorTier3 = ((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Accessibility", "LegendaryEmoteNameColor", "#FF2222", "The color of the [legendary] emote name in the terminal."); currentConfigEntries.Add(((ConfigEntryBase)unlockEverything).Definition.Key, (ConfigEntryBase)(object)unlockEverything); currentConfigEntries.Add(((ConfigEntryBase)shareEverything).Definition.Key, (ConfigEntryBase)(object)shareEverything); currentConfigEntries.Add(((ConfigEntryBase)syncUnsharedEmotes).Definition.Key, (ConfigEntryBase)(object)syncUnsharedEmotes); currentConfigEntries.Add(((ConfigEntryBase)disableRaritySystem).Definition.Key, (ConfigEntryBase)(object)disableRaritySystem); currentConfigEntries.Add(((ConfigEntryBase)basePriceEmoteRaritySystemDisabled).Definition.Key, (ConfigEntryBase)(object)basePriceEmoteRaritySystemDisabled); currentConfigEntries.Add(((ConfigEntryBase)startingEmoteCredits).Definition.Key, (ConfigEntryBase)(object)startingEmoteCredits); currentConfigEntries.Add(((ConfigEntryBase)addEmoteCreditsMultiplier).Definition.Key, (ConfigEntryBase)(object)addEmoteCreditsMultiplier); currentConfigEntries.Add(((ConfigEntryBase)purchaseEmotesWithDefaultCurrency).Definition.Key, (ConfigEntryBase)(object)purchaseEmotesWithDefaultCurrency); currentConfigEntries.Add(((ConfigEntryBase)priceMultiplierEmotesStore).Definition.Key, (ConfigEntryBase)(object)priceMultiplierEmotesStore); currentConfigEntries.Add(((ConfigEntryBase)basePriceEmoteTier0).Definition.Key, (ConfigEntryBase)(object)basePriceEmoteTier0); currentConfigEntries.Add(((ConfigEntryBase)basePriceEmoteTier1).Definition.Key, (ConfigEntryBase)(object)basePriceEmoteTier1); currentConfigEntries.Add(((ConfigEntryBase)basePriceEmoteTier2).Definition.Key, (ConfigEntryBase)(object)basePriceEmoteTier2); currentConfigEntries.Add(((ConfigEntryBase)basePriceEmoteTier3).Definition.Key, (ConfigEntryBase)(object)basePriceEmoteTier3); currentConfigEntries.Add(((ConfigEntryBase)numEmotesStoreRotation).Definition.Key, (ConfigEntryBase)(object)numEmotesStoreRotation); currentConfigEntries.Add(((ConfigEntryBase)rotationChanceEmoteTier0).Definition.Key, (ConfigEntryBase)(object)rotationChanceEmoteTier0); currentConfigEntries.Add(((ConfigEntryBase)rotationChanceEmoteTier1).Definition.Key, (ConfigEntryBase)(object)rotationChanceEmoteTier1); currentConfigEntries.Add(((ConfigEntryBase)rotationChanceEmoteTier2).Definition.Key, (ConfigEntryBase)(object)rotationChanceEmoteTier2); currentConfigEntries.Add(((ConfigEntryBase)rotationChanceEmoteTier3).Definition.Key, (ConfigEntryBase)(object)rotationChanceEmoteTier3); currentConfigEntries.Add(((ConfigEntryBase)enableMaskedEnemiesEmoting).Definition.Key, (ConfigEntryBase)(object)enableMaskedEnemiesEmoting); currentConfigEntries.Add(((ConfigEntryBase)maskedEnemiesEmoteChanceOnEncounter).Definition.Key, (ConfigEntryBase)(object)maskedEnemiesEmoteChanceOnEncounter); currentConfigEntries.Add(((ConfigEntryBase)maskedEnemiesAlwaysEmoteOnFirstEncounter).Definition.Key, (ConfigEntryBase)(object)maskedEnemiesAlwaysEmoteOnFirstEncounter); currentConfigEntries.Add(((ConfigEntryBase)enableSyncingEmotesWithMaskedEnemies).Definition.Key, (ConfigEntryBase)(object)enableSyncingEmotesWithMaskedEnemies); currentConfigEntries.Add(((ConfigEntryBase)overrideStopAndStareDuration).Definition.Key, (ConfigEntryBase)(object)overrideStopAndStareDuration); currentConfigEntries.Add(((ConfigEntryBase)maskedEnemyEmoteRandomDelay).Definition.Key, (ConfigEntryBase)(object)maskedEnemyEmoteRandomDelay); currentConfigEntries.Add(((ConfigEntryBase)maskedEnemyEmoteRandomDuration).Definition.Key, (ConfigEntryBase)(object)maskedEnemyEmoteRandomDuration); currentConfigEntries.Add(((ConfigEntryBase)disableEmotesForSelf).Definition.Key, (ConfigEntryBase)(object)disableEmotesForSelf); currentConfigEntries.Add(((ConfigEntryBase)openEmoteMenuKeybind).Definition.Key, (ConfigEntryBase)(object)openEmoteMenuKeybind); currentConfigEntries.Add(((ConfigEntryBase)rotateCharacterInEmoteKeybind).Definition.Key, (ConfigEntryBase)(object)rotateCharacterInEmoteKeybind); currentConfigEntries.Add(((ConfigEntryBase)toggleEmoteMenu).Definition.Key, (ConfigEntryBase)(object)toggleEmoteMenu); currentConfigEntries.Add(((ConfigEntryBase)reverseEmoteWheelScrollDirection).Definition.Key, (ConfigEntryBase)(object)reverseEmoteWheelScrollDirection); currentConfigEntries.Add(((ConfigEntryBase)emoteNameColorTier0).Definition.Key, (ConfigEntryBase)(object)emoteNameColorTier0); currentConfigEntries.Add(((ConfigEntryBase)emoteNameColorTier1).Definition.Key, (ConfigEntryBase)(object)emoteNameColorTier1); currentConfigEntries.Add(((ConfigEntryBase)emoteNameColorTier2).Definition.Key, (ConfigEntryBase)(object)emoteNameColorTier2); currentConfigEntries.Add(((ConfigEntryBase)emoteNameColorTier3).Definition.Key, (ConfigEntryBase)(object)emoteNameColorTier3); float value = rotationChanceEmoteTier0.Value; value += rotationChanceEmoteTier1.Value; value += rotationChanceEmoteTier2.Value; value += rotationChanceEmoteTier3.Value; if (value != 1f && value != 0f) { ConfigEntry<float> obj = rotationChanceEmoteTier0; obj.Value /= value; ConfigEntry<float> obj2 = rotationChanceEmoteTier1; obj2.Value /= value; ConfigEntry<float> obj3 = rotationChanceEmoteTier2; obj3.Value /= value; ConfigEntry<float> obj4 = rotationChanceEmoteTier3; obj4.Value /= value; ((BaseUnityPlugin)Plugin.instance).Config.Save(); } TryRemoveOldConfigSettings(); ConfigSync.BuildDefaultConfigSync(); } public static string GetDisplayName(string key) { key = key.Replace("<Keyboard>/", ""); key = key.Replace("<Mouse>/", ""); string text = key.ToLower(); text = text.Replace("leftalt", "Alt"); text = text.Replace("rightalt", "Alt"); text = text.Replace("leftctrl", "Ctrl"); text = text.Replace("rightctrl", "Ctrl"); text = text.Replace("leftshift", "Shift"); text = text.Replace("rightshift", "Shift"); text = text.Replace("leftbutton", "LMB"); text = text.Replace("rightbutton", "RMB"); text = text.Replace("middlebutton", "MMB"); text = text.Replace("backquote", "`"); try { text = char.ToUpper(text[0]) + text.Substring(1); } catch { } return text; } public static void TryRemoveOldConfigSettings() { HashSet<string> hashSet = new HashSet<string>(); HashSet<string> hashSet2 = new HashSet<string>(); foreach (ConfigEntryBase value in currentConfigEntries.Values) { hashSet.Add(value.Definition.Section); hashSet2.Add(value.Definition.Key); } try { Plugin.Log("Cleaning old config entries"); ConfigFile config = ((BaseUnityPlugin)Plugin.instance).Config; string configFilePath = config.ConfigFilePath; if (!File.Exists(configFilePath)) { return; } string text = File.ReadAllText(configFilePath); string[] array = File.ReadAllLines(configFilePath); string text2 = ""; for (int i = 0; i < array.Length; i++) { array[i] = array[i].Replace("\n", ""); if (array[i].Length <= 0) { continue; } if (array[i].StartsWith("[")) { if (text2 != "" && !hashSet.Contains(text2)) { text2 = "[" + text2 + "]"; int num = text.IndexOf(text2); int num2 = text.IndexOf(array[i]); text = text.Remove(num, num2 - num); } text2 = array[i].Replace("[", "").Replace("]", "").Trim(); } else { if (!(text2 != "")) { continue; } if (i <= array.Length - 4 && array[i].StartsWith("##")) { int j; for (j = 1; i + j < array.Length && array[i + j].Length > 3; j++) { } if (hashSet.Contains(text2)) { int num3 = array[i + j - 1].IndexOf("="); string item = array[i + j - 1].Substring(0, num3 - 1); if (!hashSet2.Contains(item)) { int num4 = text.IndexOf(array[i]); int num5 = text.IndexOf(array[i + j - 1]) + array[i + j - 1].Length; text = text.Remove(num4, num5 - num4); } } i += j - 1; } else if (array[i].Length > 3) { text = text.Replace(array[i], ""); } } } if (!hashSet.Contains(text2)) { text2 = "[" + text2 + "]"; int num6 = text.IndexOf(text2); text = text.Remove(num6, text.Length - num6); } while (text.Contains("\n\n\n")) { text = text.Replace("\n\n\n", "\n\n"); } File.WriteAllText(configFilePath, text); config.Reload(); } catch { } } } } namespace TooManyEmotes.Networking { [Serializable] [HarmonyPatch] public class ConfigSync { public static bool isSynced; public static ConfigSync defaultConfig; public static ConfigSync instance; public bool syncUnlockEverything; public bool syncShareEverything; public bool syncSyncUnsharedEmotes; public bool syncDisableRaritySystem; public int syncStartingEmoteCredits; public float syncAddEmoteCreditsMultiplier; public bool syncPurchaseEmotesWithDefaultCurrency; public float syncPriceMultiplierEmotesStore; public int syncBasePriceEmoteTier0; public int syncBasePriceEmoteTier1; public int syncBasePriceEmoteTier2; public int syncBasePriceEmoteTier3; public int syncNumEmotesStoreRotation; public float syncRotationChanceEmoteTier0; public float syncRotationChanceEmoteTier1; public float syncRotationChanceEmoteTier2; public float syncRotationChanceEmoteTier3; public bool syncEnableMaskedEnemiesEmoting; public float syncMaskedEnemiesEmoteChanceOnEncounter; public bool syncMaskedEnemiesAlwaysEmoteOnFirstEncounter; public bool syncOverrideStopAndStareDuration; public float syncMaskedEnemyEmoteRandomDelayMin; public float syncMaskedEnemyEmoteRandomDelayMax; public float syncMaskedEnemyEmoteRandomDurationMin; public float syncMaskedEnemyEmoteRandomDurationMax; public static Vector2 syncMaskedEnemyEmoteRandomDelay; public static Vector2 syncMaskedEnemyEmoteRandomDuration; public static HashSet<ulong> syncedClients; public ConfigSync() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) syncUnlockEverything = ConfigSettings.unlockEverything.Value; syncShareEverything = ConfigSettings.shareEverything.Value; syncSyncUnsharedEmotes = ConfigSettings.syncUnsharedEmotes.Value; syncDisableRaritySystem = ConfigSettings.disableRaritySystem.Value; syncStartingEmoteCredits = ConfigSettings.startingEmoteCredits.Value; syncAddEmoteCreditsMultiplier = ConfigSettings.addEmoteCreditsMultiplier.Value; syncPurchaseEmotesWithDefaultCurrency = ConfigSettings.purchaseEmotesWithDefaultCurrency.Value; syncPriceMultiplierEmotesStore = ConfigSettings.priceMultiplierEmotesStore.Value; syncNumEmotesStoreRotation = ConfigSettings.numEmotesStoreRotation.Value; syncRotationChanceEmoteTier0 = ConfigSettings.rotationChanceEmoteTier0.Value; syncRotationChanceEmoteTier1 = ConfigSettings.rotationChanceEmoteTier1.Value; syncRotationChanceEmoteTier2 = ConfigSettings.rotationChanceEmoteTier2.Value; syncRotationChanceEmoteTier3 = ConfigSettings.rotationChanceEmoteTier3.Value; syncEnableMaskedEnemiesEmoting = ConfigSettings.enableMaskedEnemiesEmoting.Value; syncMaskedEnemiesEmoteChanceOnEncounter = ConfigSettings.maskedEnemiesEmoteChanceOnEncounter.Value; syncMaskedEnemiesAlwaysEmoteOnFirstEncounter = ConfigSettings.maskedEnemiesAlwaysEmoteOnFirstEncounter.Value; syncOverrideStopAndStareDuration = ConfigSettings.overrideStopAndStareDuration.Value; syncMaskedEnemyEmoteRandomDelay = ParseVector2FromString(ConfigSettings.maskedEnemyEmoteRandomDelay.Value); syncMaskedEnemyEmoteRandomDelayMin = syncMaskedEnemyEmoteRandomDelay.x; syncMaskedEnemyEmoteRandomDelayMax = syncMaskedEnemyEmoteRandomDelay.y; syncMaskedEnemyEmoteRandomDuration = ParseVector2FromString(ConfigSettings.maskedEnemyEmoteRandomDuration.Value); syncMaskedEnemyEmoteRandomDurationMin = syncMaskedEnemyEmoteRandomDuration.x; syncMaskedEnemyEmoteRandomDurationMax = syncMaskedEnemyEmoteRandomDuration.y; if (ConfigSettings.disableRaritySystem.Value) { syncBasePriceEmoteTier0 = ConfigSettings.basePriceEmoteRaritySystemDisabled.Value; syncBasePriceEmoteTier1 = ConfigSettings.basePriceEmoteRaritySystemDisabled.Value; syncBasePriceEmoteTier2 = ConfigSettings.basePriceEmoteRaritySystemDisabled.Value; syncBasePriceEmoteTier3 = ConfigSettings.basePriceEmoteRaritySystemDisabled.Value; } else { syncBasePriceEmoteTier0 = ConfigSettings.basePriceEmoteTier0.Value; syncBasePriceEmoteTier1 = ConfigSettings.basePriceEmoteTier1.Value; syncBasePriceEmoteTier2 = ConfigSettings.basePriceEmoteTier2.Value; syncBasePriceEmoteTier3 = ConfigSettings.basePriceEmoteTier3.Value; } } public Vector2 ParseVector2FromString(string str) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Vector2 result = Vector2.zero; try { string[] array = str.Split(new char[1] { ',' }); if (float.TryParse(array[0].Trim(new char[1] { ' ' }), out var result2) && float.TryParse(array[1].Trim(new char[1] { ' ' }), out var result3)) { result = new Vector2(Mathf.Min(Mathf.Abs(result2), Mathf.Abs(result3)), Mathf.Max(Mathf.Abs(result2), Mathf.Abs(result3))); } return result; } catch { } return Vector2.zero; } public static void BuildDefaultConfigSync() { defaultConfig = new ConfigSync(); instance = new ConfigSync(); } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] public static void ResetValues() { isSynced = false; } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void Init(PlayerControllerB __instance) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown if (isSynced) { return; } isSynced = NetworkManager.Singleton.IsServer; EmoteSyncManager.isSynced = false; EmoteSyncManager.requestedSync = false; if (NetworkManager.Singleton.IsServer) { syncedClients = new HashSet<ulong>(); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("TooManyEmotes-OnRequestConfigSyncServerRpc", new HandleNamedMessageDelegate(OnRequestConfigSyncServerRpc)); if (!instance.syncUnlockEverything) { return; } { foreach (UnlockableEmote allUnlockableEmote in StartOfRoundPatcher.allUnlockableEmotes) { StartOfRoundPatcher.UnlockEmoteLocal(allUnlockableEmote); } return; } } foreach (UnlockableEmote allUnlockableEmote2 in StartOfRoundPatcher.allUnlockableEmotes) { StartOfRoundPatcher.UnlockEmoteLocal(allUnlockableEmote2); } NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("TooManyEmotes-OnRequestConfigSyncClientRpc", new HandleNamedMessageDelegate(OnRequestConfigSyncClientRpc)); RequestConfigSync(); } public static void RequestConfigSync() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsClient) { Plugin.Log("Requesting config sync from server"); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("TooManyEmotes-OnRequestConfigSyncServerRpc", 0uL, val, (NetworkDelivery)3); } else { Plugin.LogError("Failed to send unlocked emote update to server."); } } private static void OnRequestConfigSyncServerRpc(ulong clientId, FastBufferReader reader) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsServer) { Plugin.Log("Receiving config sync request from client: " + clientId); syncedClients.Add(clientId); EmoteSyncManager.syncedClients.Remove(clientId); byte[] array = SerializeConfigToByteArray(instance); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4 + array.Length, (Allocator)2, -1); int num = array.Length; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("TooManyEmotes-OnRequestConfigSyncClientRpc", clientId, val, (NetworkDelivery)3); } } private static void OnRequestConfigSyncClientRpc(ulong clientId, FastBufferReader reader) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsClient) { return; } if (((FastBufferReader)(ref reader)).TryBeginRead(4)) { int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (((FastBufferReader)(ref reader)).TryBeginRead(num)) { Plugin.Log("Receiving config sync from server."); byte[] data = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0); instance = DeserializeFromByteArray(data); syncMaskedEnemyEmoteRandomDelay = new Vector2(instance.syncMaskedEnemyEmoteRandomDelayMin, instance.syncMaskedEnemyEmoteRandomDelayMax); syncMaskedEnemyEmoteRandomDuration = new Vector2(instance.syncMaskedEnemyEmoteRandomDurationMin, instance.syncMaskedEnemyEmoteRandomDurationMax); isSynced = true; if (StartOfRoundPatcher.allUnlockableEmotes != null && StartOfRoundPatcher.unlockedEmotes != null) { StartOfRoundPatcher.ResetProgressLocal(); if (instance.syncUnlockEverything) { StartOfRoundPatcher.UnlockEmotesLocal(StartOfRoundPatcher.allUnlockableEmotes); } else { StartOfRoundPatcher.UnlockEmotesLocal(StartOfRoundPatcher.complementaryEmotes); } StartOfRoundPatcher.UpdateUnlockedFavoriteEmotes(); } } else { Plugin.LogError("Error receiving sync from server."); } } else { Plugin.LogError("Error receiving bytes length."); } } public static byte[] SerializeConfigToByteArray(ConfigSync config) { BinaryFormatter binaryFormatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); binaryFormatter.Serialize(memoryStream, config); return memoryStream.ToArray(); } public static ConfigSync DeserializeFromByteArray(byte[] data) { MemoryStream serializationStream = new MemoryStream(data); BinaryFormatter binaryFormatter = new BinaryFormatter(); return (ConfigSync)binaryFormatter.Deserialize(serializationStream); } } [HarmonyPatch] public static class EmoteSyncManager { public static bool requestedSync; public static bool isSynced; public static HashSet<ulong> syncedClients; [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] public static void ResetValues() { isSynced = false; requestedSync = false; } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void Init() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown isSynced = NetworkManager.Singleton.IsServer; requestedSync = NetworkManager.Singleton.IsServer; if (NetworkManager.Singleton.IsServer) { syncedClients = new HashSet<ulong>(); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("TooManyEmotes-OnRequestSyncServerRpc", new HandleNamedMessageDelegate(OnRequestSyncServerRpc)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("TooManyEmotes-OnUnlockEmoteServerRpc", new HandleNamedMessageDelegate(OnUnlockEmoteServerRpc)); } else { NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("TooManyEmotes-OnRequestSyncClientRpc", new HandleNamedMessageDelegate(OnRequestSyncClientRpc)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("TooManyEmotes-OnUnlockEmoteClientRpc", new HandleNamedMessageDelegate(OnUnlockEmoteClientRpc)); NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("TooManyEmotes-OnRotateEmotesClientRpc", new HandleNamedMessageDelegate(RotateEmoteSelectionClientRpc)); } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void RequestSyncAfterConfigUpdate(PlayerControllerB __instance) { if (!isSynced && !requestedSync && ConfigSync.isSynced && (Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController) { SendSyncRequest(); requestedSync = true; } } public static void SendSyncRequest() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsClient) { Plugin.Log("Sending sync request to server."); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("TooManyEmotes-OnRequestSyncServerRpc", 0uL, val, (NetworkDelivery)3); } } private static void OnRequestSyncServerRpc(ulong clientId, FastBufferReader reader) { if (NetworkManager.Singleton.IsServer) { Plugin.Log("Receiving sync request from client: " + clientId); ServerSendSyncToClient(clientId); } } public static void ServerSendSyncToClient(ulong clientId) { //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer || !ConfigSync.syncedClients.Contains(clientId)) { return; } PlayerControllerB playerController = null; StartOfRoundPatcher.TryGetPlayerByClientId(clientId, out playerController); if ((Object)(object)playerController != (Object)null) { if (!StartOfRoundPatcher.unlockedEmotesByPlayer.ContainsKey(playerController.playerUsername)) { StartOfRoundPatcher.unlockedEmotesByPlayer.Add(playerController.playerUsername, new List<UnlockableEmote>()); } if (!TerminalPatcher.currentEmoteCreditsByPlayer.ContainsKey(playerController.playerUsername)) { TerminalPatcher.currentEmoteCreditsByPlayer.Add(playerController.playerUsername, ConfigSync.instance.syncStartingEmoteCredits); } } List<UnlockableEmote> list = StartOfRoundPatcher.unlockedEmotes; int num = TerminalPatcher.currentEmoteCredits; if (!ConfigSync.instance.syncUnlockEverything && !ConfigSync.instance.syncShareEverything) { if ((Object)(object)playerController != (Object)null) { if (StartOfRoundPatcher.unlockedEmotesByPlayer.TryGetValue(playerController.playerUsername, out var value)) { Plugin.Log("Loading " + value.Count + " unlocked emotes for player: " + playerController.playerUsername); list = value; } if (TerminalPatcher.currentEmoteCreditsByPlayer.TryGetValue(playerController.playerUsername, out var value2)) { Plugin.Log("Loading " + value2 + " emote credits for player: " + playerController.playerUsername); num = value2; } } else { Plugin.LogError("Error loading custom emotes for player. Player with id: " + clientId + " does not exist?"); list = StartOfRoundPatcher.complementaryEmotes; num = ConfigSync.instance.syncStartingEmoteCredits; } } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(12 + 4 * list.Count, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref TerminalPatcher.emoteStoreSeed, default(ForPrimitives)); int count = list.Count; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref count, default(ForPrimitives)); for (int i = 0; i < list.Count; i++) { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref list[i].emoteId, default(ForPrimitives)); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("TooManyEmotes-OnRequestSyncClientRpc", clientId, val, (NetworkDelivery)3); } private static void OnRequestSyncClientRpc(ulong clientId, FastBufferReader reader) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsClient || !ConfigSync.isSynced) { return; } isSynced = true; if (((FastBufferReader)(ref reader)).TryBeginRead(12)) { StartOfRoundPatcher.ResetProgressLocal(); ((FastBufferReader)(ref reader)).ReadValue<int>(ref TerminalPatcher.currentEmoteCredits, default(ForPrimitives)); ((FastBufferReader)(ref reader)).ReadValue<int>(ref TerminalPatcher.emoteStoreSeed, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValue<int>(ref num, default(ForPrimitives)); TerminalPatcher.RotateNewEmoteSelection(); Plugin.Log("Receiving sync from server. CurrentEmoteCredits: " + TerminalPatcher.currentEmoteCredits + " EmoteStoreSeed: " + TerminalPatcher.emoteStoreSeed + " NumEmotes: " + num); if (num <= 0) { if (num == -1) { StartOfRoundPatcher.ResetEmotesLocal(); } } else { if (!((FastBufferReader)(ref reader)).TryBeginRead(4 * num)) { Plugin.LogError("Error receiving emotes sync from server."); return; } int emoteId = default(int); for (int i = 0; i < num; i++) { ((FastBufferReader)(ref reader)).ReadValue<int>(ref emoteId, default(ForPrimitives)); StartOfRoundPatcher.UnlockEmoteLocal(emoteId); } } isSynced = true; Plugin.Log("Received sync from server."); } else { Plugin.LogError("Error receiving sync from server."); } } public static void SendOnUnlockEmoteUpdate(int emoteId, int newEmoteCredits = -1) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(12, (Allocator)2, -1); Plugin.Log("Sending unlocked emote update to server. Emote id: " + emoteId); ((FastBufferWriter)(ref val)).WriteValue<int>(ref newEmoteCredits, default(ForPrimitives)); int num = 1; ((FastBufferWriter)(ref val)).WriteValue<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValue<int>(ref emoteId, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("TooManyEmotes-OnUnlockEmoteServerRpc", 0uL, val, (NetworkDelivery)3); } public static void SendOnUnlockEmoteUpdateMulti(int newEmoteCredits = -1) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8 + 4 * StartOfRoundPatcher.unlockedEmotes.Count, (Allocator)2, -1); Plugin.Log("Sending all unlocked emotes update to server."); ((FastBufferWriter)(ref val)).WriteValue<int>(ref newEmoteCredits, default(ForPrimitives)); int count = StartOfRoundPatcher.unlockedEmotes.Count; ((FastBufferWriter)(ref val)).WriteValue<int>(ref count, default(ForPrimitives)); foreach (UnlockableEmote unlockedEmote in StartOfRoundPatcher.unlockedEmotes) { ((FastBufferWriter)(ref val)).WriteValue<int>(ref unlockedEmote.emoteId, default(ForPrimitives)); } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("TooManyEmotes-OnUnlockEmoteServerRpc", 0uL, val, (NetworkDelivery)3); } private static void OnUnlockEmoteServerRpc(ulong clientId, FastBufferReader reader) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { return; } if (((FastBufferReader)(ref reader)).TryBeginRead(8)) { int num = default(int); ((FastBufferReader)(ref reader)).ReadValue<int>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValue<int>(ref num2, default(ForPrimitives)); PlayerControllerB playerController = null; StartOfRoundPatcher.TryGetPlayerByClientId(clientId, out playerController); if (num != -1) { if (!ConfigSync.instance.syncShareEverything && clientId != 0) { if ((Object)(object)playerController != (Object)null) { TerminalPatcher.currentEmoteCreditsByPlayer[playerController.playerUsername] = num; } } else { TerminalPatcher.currentEmoteCredits = num; } } Plugin.Log("Receiving unlocked emote update from client for " + num2 + " emotes."); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16 + 4 * num2, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref clientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref TerminalPatcher.currentEmoteCredits, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num2, default(ForPrimitives)); if (((FastBufferReader)(ref reader)).TryBeginRead(4 * num2)) { int emoteId = default(int); for (int i = 0; i < num2; i++) { ((FastBufferReader)(ref reader)).ReadValue<int>(ref emoteId, default(ForPrimitives)); if (!ConfigSync.instance.syncShareEverything && clientId != 0) { if ((Object)(object)playerController != (Object)null) { StartOfRoundPatcher.UnlockEmoteLocal(emoteId, playerController.playerUsername); } } else { StartOfRoundPatcher.UnlockEmoteLocal(emoteId); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref emoteId, default(ForPrimitives)); } } NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("TooManyEmotes-OnUnlockEmoteClientRpc", val, (NetworkDelivery)3); } else { Plugin.LogError("Failed to receive unlocked emote updates from client. Expected updates: " + num2); } } else { Plugin.LogError("Failed to receive unlocked emote update from client."); } } private static void OnUnlockEmoteClientRpc(ulong clientId, FastBufferReader reader) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsClient || NetworkManager.Singleton.IsServer) { return; } if (((FastBufferReader)(ref reader)).TryBeginRead(16)) { ulong clientId2 = default(ulong); ((FastBufferReader)(ref reader)).ReadValue<ulong>(ref clientId2, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValue<int>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValue<int>(ref num2, default(ForPrimitives)); PlayerControllerB playerController = null; if (!ConfigSync.instance.syncShareEverything && !StartOfRoundPatcher.TryGetPlayerByClientId(clientId2, out playerController)) { return; } if (num != -1) { TerminalPatcher.currentEmoteCredits = num; } if (((FastBufferReader)(ref reader)).TryBeginRead(4 * num2)) { int emoteId = default(int); for (int i = 0; i < num2; i++) { ((FastBufferReader)(ref reader)).ReadValue<int>(ref emoteId, default(ForPrimitives)); Plugin.Log("Receiving unlocked emote update from server. Emote id: " + emoteId); if (ConfigSync.instance.syncShareEverything) { StartOfRoundPatcher.UnlockEmoteLocal(emoteId); } else { StartOfRoundPatcher.UnlockEmoteLocal(emoteId, playerController.playerUsername); } } } else { Plugin.LogError("Failed to receive unlocked emote updates from client. Expected updates: " + num2); } } else { Plugin.LogError("Failed to receive unlocked emote update from client."); } } public static void RotateEmoteSelectionServerRpc(int overrideSeed = 0) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { TerminalPatcher.emoteStoreSeed = ((overrideSeed == 0) ? Random.Range(0, 1000000000) : overrideSeed); TerminalPatcher.RotateNewEmoteSelection(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); ((FastBufferWriter)(ref val)).WriteValue<int>(ref TerminalPatcher.emoteStoreSeed, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("TooManyEmotes-OnRotateEmotesClientRpc", val, (NetworkDelivery)3); } } private static void RotateEmoteSelectionClientRpc(ulong clientId, FastBufferReader reader) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer && ((FastBufferReader)(ref reader)).TryBeginRead(4)) { ((FastBufferReader)(ref reader)).ReadValue<int>(ref TerminalPatcher.emoteStoreSeed, default(ForPrimitives)); TerminalPatcher.RotateNewEmoteSelection(); } } } } namespace TooManyEmotes.CompatibilityPatcher { [HarmonyPatch] internal class MoreEmotesPatcher { public static bool loadedMoreEmotes; [HarmonyPatch(typeof(PreInitSceneScript), "Awake")] [HarmonyPostfix] public static void ApplyPatch() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown if (!Plugin.IsModLoaded("MoreEmotes") || !Chainloader.PluginInfos.TryGetValue("MoreEmotes", out var value)) { return; } Assembly assembly = ((object)value.Instance).GetType().Assembly; if (assembly != null) { Plugin.Log("Applying compatibility patch for More_Emotes"); Type type = assembly.GetType("MoreEmotes.Patch.EmotePatch"); FieldInfo field = type.GetField("local", BindingFlags.Static | BindingFlags.Public); RuntimeAnimatorController val = (RuntimeAnimatorController)field.GetValue(null); if ((Object)(object)val != (Object)null && !(val is AnimatorOverrideController)) { field.SetValue(null, (object?)new AnimatorOverrideController(val)); } FieldInfo field2 = type.GetField("others", BindingFlags.Static | BindingFlags.Public); RuntimeAnimatorController val2 = (RuntimeAnimatorController)field2.GetValue(null); if ((Object)(object)val2 != (Object)null && !(val2 is AnimatorOverrideController)) { field2.SetValue(null, (object?)new AnimatorOverrideController(val2)); } } } } [HarmonyPatch] internal class BetterEmotesPatcher { public static bool loadedBetterEmotes; [HarmonyPatch(typeof(PreInitSceneScript), "Awake")] [HarmonyPostfix] public static void ApplyPatch() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown if (!Plugin.IsModLoaded("BetterEmotes") || !Chainloader.PluginInfos.TryGetValue("BetterEmotes", out var value)) { return; } Assembly assembly = ((object)value.Instance).GetType().Assembly; if (assembly != null) { Plugin.Log("Applying compatibility patch for BetterEmotes"); Type type = assembly.GetType("BetterEmote.EmotePatch"); FieldInfo field = type.GetField("local", BindingFlags.Static | BindingFlags.Public); RuntimeAnimatorController val = (RuntimeAnimatorController)field.GetValue(null); if ((Object)(object)val != (Object)null && !(val is AnimatorOverrideController)) { field.SetValue(null, (object?)new AnimatorOverrideController(val)); } FieldInfo field2 = type.GetField("others", BindingFlags.Static | BindingFlags.Public); RuntimeAnimatorController val2 = (RuntimeAnimatorController)field2.GetValue(null); if ((Object)(object)val2 != (Object)null && !(val2 is AnimatorOverrideController)) { field2.SetValue(null, (object?)new AnimatorOverrideController(val2)); } } } } internal class BiggerLobbyPatcher { public static bool loadedBiggerLobby; [HarmonyPatch(typeof(NetworkSceneManager), "PopulateScenePlacedObjects")] [HarmonyPostfix] public static void ApplyPatch() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown if (!Plugin.IsModLoaded("BiggerLobby")) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } for (int i = 0; i < instance.allPlayerScripts.Length; i++) { PlayerControllerB obj = instance.allPlayerScripts[i]; object obj2; if (obj == null) { obj2 = null; } else { Animator playerBodyAnimator = obj.playerBodyAnimator; obj2 = ((playerBodyAnimator != null) ? playerBodyAnimator.runtimeAnimatorController : null); } if ((Object)obj2 != (Object)null) { instance.allPlayerScripts[i].playerBodyAnimator.runtimeAnimatorController = (RuntimeAnimatorController)new AnimatorOverrideController(instance.otherClientsAnimatorController); } } loadedBiggerLobby = true; } } [HarmonyPatch] internal class MoreCompanyPatcher { public static bool loadedMoreCompany = false; public static List<GameObject> cosmeticInstances = new List<GameObject>(); [HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")] [HarmonyPostfix] public static void ApplyPatch() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany")) { return; } CosmeticApplication val = Object.FindObjectOfType<CosmeticApplication>(); if (CosmeticRegistry.locallySelectedCosmetics.Count <= 0 || val.spawnedCosmetics.Count > 0) { return; } foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics) { val.ApplyCosmetic(locallySelectedCosmetic, true); } foreach (CosmeticInstance spawnedCosmetic in val.spawnedCosmetics) { Transform transform = ((Component)spawnedCosmetic).transform; transform.localScale *= 0.38f; SetAllChildrenLayer(((Component)spawnedCosmetic).transform, 23); } } private static void SetAllChildrenLayer(Transform transform, int layer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown ((Component)transform).gameObject.layer = layer; foreach (Transform item in transform) { Transform transform2 = item; SetAllChildrenLayer(transform2, layer); } } } [HarmonyPatch] internal class MirrorDecorPatcher { public static bool loadedMirrorDecor; [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPrefix] public static void ApplyPatch() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Plugin.IsModLoaded("quackandcheese.mirrordecor")) { loadedMirrorDecor = true; ThirdPersonEmoteController.localPlayerBodyLayer = 23; ThirdPersonEmoteController.defaultShadowCastingMode = (ShadowCastingMode)1; Plugin.Log("Applied patch for MirrorDecor"); } } } } namespace TooManyEmotes.Patches { [HarmonyPatch] public static class BoomboxMusicPlayer { public static List<BoomboxItem> allBoomboxes = new List<BoomboxItem>(); [HarmonyPatch(typeof(BoomboxItem), "Start")] [HarmonyPostfix] public static void AddBoomboxToPool(BoomboxItem __instance) { } public static void OnPlayEmoteWithMusic(UnlockableEmote emote, PlayerControllerB playerController) { if (Plugin.musicClips.ContainsKey(emote.emoteName)) { BoomboxItem nearestBoombox = GetNearestBoombox(playerController); if (!((Object)(object)nearestBoombox == (Object)null) && (!nearestBoombox.isPlayingMusic || !Plugin.musicClips.ContainsKey(((Object)nearestBoombox.boomboxAudio.clip).name))) { AudioClip val = Plugin.musicClips[emote.emoteName]; nearestBoombox.boomboxAudio.PlayOneShot(val); } } } public static BoomboxItem GetNearestBoombox(PlayerControllerB playerController) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) BoomboxItem result = null; float num = 10f; foreach (BoomboxItem allBoombox in allBoomboxes) { float num2 = Vector3.Distance(((Component)playerController).transform.position, ((Component)allBoombox).transform.position); if ((Object)(object)allBoombox != (Object)null && num2 < num) { result = allBoombox; num = num2; } } return result; } } [HarmonyPatch] public class MaskedEnemyEmotes { public static Dictionary<MaskedPlayerEnemy, MaskedEnemyData> spawnedMaskedEnemyData = new Dictionary<MaskedPlayerEnemy, MaskedEnemyData>(); public static AnimationClip defaultIdleClip; public static HashSet<PlayerControllerB> playersEmotedWithThisRound = new HashSet<PlayerControllerB>(); public static int currentLevelSeed => StartOfRound.Instance.randomMapSeed; [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] public static void ResetValues(StartOfRound __instance) { if (ConfigSync.instance.syncEnableMaskedEnemiesEmoting) { spawnedMaskedEnemyData.Clear(); } } [HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")] [HarmonyPostfix] public static void InitMaskedEnemy(MaskedPlayerEnemy __instance) { if (ConfigSync.instance.syncEnableMaskedEnemiesEmoting) { MaskedEnemyData maskedEnemyData = new MaskedEnemyData(__instance); spawnedMaskedEnemyData.Add(__instance, maskedEnemyData); if ((Object)(object)defaultIdleClip == (Object)null) { defaultIdleClip = maskedEnemyData.animatorController["Idle"]; } } } [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPrefix] public static void OnLoadNewLevel(MaskedPlayerEnemy __instance) { if (ConfigSync.instance.syncEnableMaskedEnemiesEmoting
plugins/TooManySuits.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreSuits; using TMPro; using TooManySuits.Helper; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [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("TooManySuits")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TooManySuits")] [assembly: AssemblyTitle("TooManySuits")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } 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; } } } namespace TooManySuits { [BepInPlugin("verity.TooManySuits", "Too Many Suits", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static ManualLogSource LogSource; public static ConfigEntry<string> NextButton; public static ConfigEntry<string> BackButton; public static ConfigEntry<float> TextScale; private void Awake() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown LogSource = ((BaseUnityPlugin)this).Logger; NextButton = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Next-Page-Keybind", "<Keyboard>/n", "Next page button."); BackButton = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Back-Page-Keybind", "<Keyboard>/b", "Back page button."); TextScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Text-Scale", 0.003f, "Size of the text above the suit rack."); GameObject val = new GameObject("TooManySuits"); val.AddComponent<PluginLoader>(); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)val); } } public class PluginLoader : MonoBehaviour { private class Hooks { public static bool SetUI; public static GameObject SuitPanel; public static void HookStartGame() { Plugin.LogSource.LogInfo((object)"StartOfRound!"); Object.Instantiate<GameObject>(suitSelectBundle.LoadAsset<GameObject>("SuitSelect")); SuitPanel = GameObject.Find("SuitPanel"); SuitPanel.SetActive(false); SetUI = true; } } private readonly Harmony Harmony = new Harmony("TooManySuits"); private InputAction moveRightAction; private InputAction moveLeftAction; private int currentPage; private int suitsPerPage = 13; private int suitsLength; private UnlockableSuit[] allSuits; private static AssetBundle suitSelectBundle; private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown Plugin.LogSource.LogInfo((object)"TooManySuits Mod Loaded."); moveRightAction = new InputAction((string)null, (InputActionType)0, Plugin.NextButton.Value, (string)null, (string)null, (string)null); moveRightAction.performed += MoveRightAction; moveRightAction.Enable(); moveLeftAction = new InputAction((string)null, (InputActionType)0, Plugin.BackButton.Value, (string)null, (string)null, (string)null); moveLeftAction.performed += MoveLeftAction; moveLeftAction.Enable(); MethodInfo method = typeof(StartOfRound).GetMethod("Start", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo method2 = typeof(Hooks).GetMethod("HookStartGame"); Harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo method3 = typeof(PlayerControllerB).GetMethod("Start", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo method4 = typeof(LocalPlayer).GetMethod("PlayerControllerStart"); Harmony.Patch((MethodBase)method3, (HarmonyMethod)null, new HarmonyMethod(method4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); suitSelectBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "suitselect")); if (MoreSuitsMod.MakeSuitsFitOnRack) { suitsPerPage = 20; } } private void Update() { if (!((Object)(object)StartOfRound.Instance == (Object)null)) { allSuits = (from suit in Resources.FindObjectsOfTypeAll<UnlockableSuit>() orderby suit.syncedSuitID.Value select suit).ToArray(); DisplaySuits(); } } private void DisplaySuits() { //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) if (allSuits.Length == 0) { return; } int num = currentPage * suitsPerPage; int num2 = Mathf.Min(num + suitsPerPage, allSuits.Length); int num3 = 0; for (int i = 0; i < allSuits.Length; i++) { UnlockableSuit val = allSuits[i]; AutoParentToShip component = ((Component)val).gameObject.GetComponent<AutoParentToShip>(); if ((Object)(object)component == (Object)null) { continue; } bool flag = i >= num && i < num2; ((Component)val).gameObject.SetActive(flag); if (flag) { component.overrideOffset = true; if (MoreSuitsMod.MakeSuitsFitOnRack && suitsLength > 13) { float num4 = 0.18f; num4 /= (float)Math.Min(suitsLength, 20) / 12f; component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + StartOfRound.Instance.rightmostSuitPosition.forward * (num4 * (float)num3); component.rotationOffset = new Vector3(0f, 90f, 0f); } else { component.positionOffset = new Vector3(-2.45f, 2.75f, -8.41f) + StartOfRound.Instance.rightmostSuitPosition.forward * (0.18f * (float)num3); component.rotationOffset = new Vector3(0f, 90f, 0f); } num3++; } } suitsLength = allSuits.Length; if (!LocalPlayer.isActive()) { return; } if (LocalPlayer.localPlayer.isInHangarShipRoom) { ((TMP_Text)Hooks.SuitPanel.GetComponentInChildren<TextMeshProUGUI>()).text = $"Page {currentPage + 1}/{suitsLength / suitsPerPage + 1}"; Hooks.SuitPanel.SetActive(true); return; } Hooks.SuitPanel.SetActive(false); if (Hooks.SetUI) { Hooks.SetUI = false; Hooks.SuitPanel.GetComponentInParent<Canvas>().renderMode = (RenderMode)2; Hooks.SuitPanel.GetComponentInParent<Canvas>().worldCamera = LocalPlayer.localPlayer.gameplayCamera; Transform transform = Hooks.SuitPanel.transform; Bounds bounds = StartOfRound.Instance.shipBounds.bounds; transform.position = ((Bounds)(ref bounds)).center - new Vector3(2.8992f, 0.7998f, 2f); Hooks.SuitPanel.transform.rotation = Quaternion.Euler(0f, 180f, 0f); Hooks.SuitPanel.transform.localScale = new Vector3(Plugin.TextScale.Value, Plugin.TextScale.Value, Plugin.TextScale.Value); Hooks.SuitPanel.SetActive(true); } } private void MoveRightAction(CallbackContext obj) { currentPage = Mathf.Min(currentPage + 1, Mathf.CeilToInt((float)suitsLength / (float)suitsPerPage) - 1); } private void MoveLeftAction(CallbackContext obj) { currentPage = Mathf.Max(currentPage - 1, 0); } } } namespace TooManySuits.Helper { public class LocalPlayer { public static PlayerControllerB localPlayer; public static bool isActive() { return (Object)(object)localPlayer != (Object)null; } public static void PlayerControllerStart(PlayerControllerB __instance) { if (NetworkManager.Singleton.LocalClientId == __instance.playerClientId) { localPlayer = __instance; } } } }
plugins/TurretAlwaysLaserMod.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using TurretAlwaysLaserMod.Patches; 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("TurretAlwaysLaserMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TurretAlwaysLaserMod")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a0c00b42-5017-458e-a3bd-9e36458950fc")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace TurretAlwaysLaserMod { [BepInPlugin("tolstj.turretAlwaysLaser", "Turret Always Laser", "1.0.0.0")] public class TurretAlwaysLaserModBase : BaseUnityPlugin { private const string modGUID = "tolstj.turretAlwaysLaser"; private const string modName = "Turret Always Laser"; private const string modVersion = "1.0.0.0"; private readonly Harmony harmony = new Harmony("tolstj.turretAlwaysLaser"); private void Awake() { harmony.PatchAll(typeof(TurretPatch)); } } } namespace TurretAlwaysLaserMod.Patches { [HarmonyPatch(typeof(Turret))] internal class TurretPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void TurretDetectionToChargingPatch(ref Animator ___turretAnimator, ref TurretMode ___turretMode) { if ((int)___turretMode == 0) { ___turretAnimator.SetInteger("TurretMode", 1); } } } }
plugins/TVLoader.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using TVLoader.Utils; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("TVLoader")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TVLoader")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e59845a7-f2f7-4416-9a61-ca1939ce6e2d")] [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 TVLoader { [BepInPlugin("rattenbonkers.TVLoader", "TVLoader", "1.0.3")] public class TVLoaderPlugin : BaseUnityPlugin { private const string MyGUID = "rattenbonkers.TVLoader"; private const string PluginName = "TVLoader"; private const string VersionString = "1.0.3"; private static readonly Harmony Harmony = new Harmony("rattenbonkers.TVLoader"); public static ManualLogSource Log = new ManualLogSource("TVLoader"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Harmony.PatchAll(); VideoManager.Load(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("PluginName: {0}, VersionString: {1} is loaded. Video Count: ${2}", "TVLoader", "1.0.3", VideoManager.Videos.Count)); } } } namespace TVLoader.Utils { internal static class VideoManager { public static List<string> Videos = new List<string>(); public static void Load() { string[] directories = Directory.GetDirectories(Paths.PluginPath); foreach (string text in directories) { string path = Path.Combine(Paths.PluginPath, text, "Television Videos"); if (Directory.Exists(path)) { string[] files = Directory.GetFiles(path, "*.mp4"); Videos.AddRange(files); TVLoaderPlugin.Log.LogInfo((object)$"{text} has {files.Length} videos."); } } string path2 = Path.Combine(Paths.PluginPath, "Television Videos"); if (!Directory.Exists(path2)) { Directory.CreateDirectory(path2); } string[] files2 = Directory.GetFiles(path2, "*.mp4"); Videos.AddRange(files2); TVLoaderPlugin.Log.LogInfo((object)$"Global has {files2.Length} videos."); TVLoaderPlugin.Log.LogInfo((object)$"Loaded {Videos.Count} total."); } } } namespace TVLoader.Patches { [HarmonyPatch(typeof(TVScript))] internal class TVScriptPatches { private static FieldInfo currentClipProperty = typeof(TVScript).GetField("currentClip", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo currentTimeProperty = typeof(TVScript).GetField("currentClipTime", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo wasLastFrameProp = typeof(TVScript).GetField("wasTvOnLastFrame", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo timeSinceTurningOffTVProp = typeof(TVScript).GetField("timeSinceTurningOffTV", BindingFlags.Instance | BindingFlags.NonPublic); private static MethodInfo setMatProperty = typeof(TVScript).GetMethod("SetTVScreenMaterial", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPatch(typeof(TVScript), "Update")] [HarmonyPrefix] public static bool Update(TVScript __instance) { return false; } [HarmonyPatch(typeof(TVScript), "TurnTVOnOff")] [HarmonyPrefix] public static bool TurnTVOnOff(TVScript __instance, bool on) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if (VideoManager.Videos.Count == 0) { return false; } if ((int)__instance.video.source != 1) { __instance.video.clip = null; __instance.tvSFX.clip = null; } __instance.tvOn = on; if (on) { PlayNextVideo(__instance); __instance.tvSFX.PlayOneShot(__instance.switchTVOn); WalkieTalkie.TransmitOneShotAudio(__instance.tvSFX, __instance.switchTVOn, 1f); } else { __instance.video.Stop(); __instance.tvSFX.PlayOneShot(__instance.switchTVOff); WalkieTalkie.TransmitOneShotAudio(__instance.tvSFX, __instance.switchTVOff, 1f); } setMatProperty.Invoke(__instance, new object[1] { on }); return false; } [HarmonyPatch(typeof(TVScript), "TVFinishedClip")] [HarmonyPrefix] public static bool TVFinishedClip(TVScript __instance, VideoPlayer source) { PlayNextVideo(__instance); return false; } private static void PlayNextVideo(TVScript instance) { if (VideoManager.Videos.Count != 0) { TVLoaderPlugin.Log.LogInfo((object)"Playing next video..."); int num = (int)currentClipProperty.GetValue(instance); num = (num + 1) % VideoManager.Videos.Count; TVLoaderPlugin.Log.LogInfo((object)$"currentClip: {num} - {VideoManager.Videos[num]}"); currentTimeProperty.SetValue(instance, 0f); currentClipProperty.SetValue(instance, num); instance.tvSFX.time = 0f; instance.video.url = "file://" + VideoManager.Videos[num]; instance.video.source = (VideoSource)1; instance.video.controlledAudioTrackCount = 1; instance.video.audioOutputMode = (VideoAudioOutputMode)1; instance.video.SetTargetAudioSource((ushort)0, instance.tvSFX); instance.video.Play(); instance.SyncTVServerRpc(); } } } }
plugins/WeepingAngels/WeepingAngels.dll
Decompiled 2 years agousing System; 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 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.6", FrameworkDisplayName = "")] [assembly: AssemblyCompany("WeepingAngel")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Change coilhead model to a wheeping angel")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WeepingAngel")] [assembly: AssemblyTitle("WeepingAngel")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 WeepingAngel { [BepInPlugin("raydenoir.WeepingAngel", "WeepingAngel", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string BundleFolderPath = "assets/weepingangels/"; public static ConfigEntry<bool> EnableConcreteSounds; public static string PluginDirectory; public static ManualLogSource Logging; public static AudioClip Concrete; public static GameObject[] AngelModel; public static AssetBundle Bundle; private void Awake() { PluginDirectory = ((BaseUnityPlugin)this).Info.Location; Logging = ((BaseUnityPlugin)this).Logger; EnableConcreteSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("Sounds", "EnableConcreteSounds", false, "true/false: If set to true, enables concrete grinding walking sounds instead of silence."); LoadAssets(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin raydenoir.WeepingAngel is loaded!"); } private void LoadAssets() { try { Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PluginDirectory), "weepingangels")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Couldn't load asset bundle: " + ex.Message)); return; } try { if (EnableConcreteSounds.Value) { Concrete = Bundle.LoadAsset<AudioClip>("assets/weepingangels/concrete.wav"); } AngelModel = (GameObject[])(object)new GameObject[3]; for (int i = 0; i < 3; i++) { AngelModel[i] = Bundle.LoadAsset<GameObject>("assets/weepingangels/angel" + (i + 1) + ".prefab"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded assets."); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("Couldn't load assets: " + ex2.Message)); } } } public static class PluginInfo { public const string PLUGIN_GUID = "WeepingAngel"; public const string PLUGIN_NAME = "WeepingAngel"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace WeepingAngel.Patches { [HarmonyPatch] public class CoilheadPatch : MonoBehaviour { public static ManualLogSource Logging = Plugin.Logging; [HarmonyPatch(typeof(EnemyAI), "Start")] [HarmonyPostfix] public static void Summon173(EnemyAI __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (__instance is SpringManAI) { SpringManAI val; try { val = (SpringManAI)__instance; } catch (Exception ex) { Logging.LogError((object)("Couldn't cast EnemyAI instance to SpringManAI: " + ex.Message)); return; } Object.Destroy((Object)(object)((Component)((Component)val).transform.Find("SpringManModel").Find("Body")).gameObject.GetComponent<SkinnedMeshRenderer>()); Object.Destroy((Object)(object)((Component)((Component)val).transform.Find("SpringManModel").Find("Head")).gameObject.GetComponent<MeshRenderer>()); ((Component)((Component)val).transform.Find("SpringManModel").Find("FoostepSFX")).gameObject.GetComponent<AudioSource>().mute = true; InstantiateAngel(val); val.springNoises = (AudioClip[])(object)new AudioClip[1]; Logging.LogInfo((object)"Weeping Angel resources are loaded."); } } private static void InstantiateAngel(SpringManAI parent) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (Plugin.AngelModel != null && !((Object)(object)Plugin.AngelModel[0] == (Object)null)) { int num = new Random().Next(0, 3); GameObject val = Object.Instantiate<GameObject>(Plugin.AngelModel[num]); val.transform.SetParent(((Component)parent).transform.Find("SpringManModel")); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; } } private static void ChangeAngelPose(SpringManAI parent) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (Plugin.AngelModel != null && !((Object)(object)Plugin.AngelModel[0] == (Object)null)) { Transform val = ((Component)parent).transform.Find("SpringManModel"); Object.Destroy((Object)(object)((Component)val.GetChild(val.childCount - 1)).gameObject); int num = new Random().Next(0, 3); GameObject val2 = Object.Instantiate<GameObject>(Plugin.AngelModel[num]); val2.transform.SetParent(((Component)parent).transform.Find("SpringManModel")); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; } } [HarmonyPatch(typeof(SpringManAI), "SetAnimationGoClientRpc")] [HarmonyPostfix] [ClientRpc] public static void PlayWalkSounds(SpringManAI __instance) { ChangeAngelPose(__instance); if (Plugin.EnableConcreteSounds.Value && !((Object)(object)Plugin.Concrete == (Object)null)) { ((EnemyAI)__instance).creatureSFX.PlayOneShot(Plugin.Concrete, 0.6f); WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureSFX, Plugin.Concrete, 0.4f); } } [HarmonyPatch(typeof(SpringManAI), "SetAnimationStopClientRpc")] [HarmonyPostfix] [ClientRpc] public static void StopWalkSounds(SpringManAI __instance) { if (Plugin.EnableConcreteSounds.Value && !((Object)(object)Plugin.Concrete == (Object)null) && ((EnemyAI)__instance).creatureSFX.isPlaying) { ((EnemyAI)__instance).creatureSFX.Stop(); } } } }