Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValheimRoleplay v2.1.2
files/plugins/BestDressed.dll
Decompiled a day 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.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BestDressed.Helpers; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: AssemblyFileVersion("1.0.0")] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyProduct("BestDressed")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("BestDressed")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Arielle")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: <ac7ba4dc-7a69-458f-8ab4-76ebfc7b732d>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<cb177d32-ba36-489a-b7cb-04ae12cd0a6a>Embedded] internal sealed class <cb177d32-ba36-489a-b7cb-04ae12cd0a6a>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<cb177d32-ba36-489a-b7cb-04ae12cd0a6a>Embedded] internal sealed class <88aceaad-7e9d-4b79-b728-8e2d9405707b>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <88aceaad-7e9d-4b79-b728-8e2d9405707b>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <88aceaad-7e9d-4b79-b728-8e2d9405707b>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<cb177d32-ba36-489a-b7cb-04ae12cd0a6a>Embedded] [CompilerGenerated] internal sealed class <47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContextAttribute : Attribute { public readonly byte Flag; public <47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContextAttribute(byte P_0) { Flag = P_0; } } [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [CompilerGenerated] [<cb177d32-ba36-489a-b7cb-04ae12cd0a6a>Embedded] internal sealed class <ac7ba4dc-7a69-458f-8ab4-76ebfc7b732d>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <ac7ba4dc-7a69-458f-8ab4-76ebfc7b732d>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BestDressed { [Serializable] [<88aceaad-7e9d-4b79-b728-8e2d9405707b>Nullable(0)] [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] public class OriginalLook { public int? OriginalGender; public string OriginalHair; public string OriginalBeard; public Vector3 OriginalSkinColor; public Vector3 OriginalHairColor; } [<88aceaad-7e9d-4b79-b728-8e2d9405707b>Nullable(0)] [BepInPlugin("Arielle.BestDressed", "BestDressed", "1.0.0")] [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] public class BestDressedPlugin : BaseUnityPlugin { internal const string ModName = "BestDressed"; internal const string ModVersion = "1.0.0"; internal const string Author = "Arielle"; private const string ModGUID = "Arielle.BestDressed"; public static RuntimeAnimatorController CustomRuntime; public static Dictionary<string, string> Humanoids = new Dictionary<string, string>(); [<88aceaad-7e9d-4b79-b728-8e2d9405707b>Nullable(new byte[] { 1, 0, 1, 1 })] public static IEnumerable<KeyValuePair<string, string>> OrderedHumanoids; public static Dictionary<string, string> replacementMap = new Dictionary<string, string>(); public static Dictionary<string, AnimationClip> ExternalAnimations = new Dictionary<string, AnimationClip>(); public static OriginalLook OGLook = new OriginalLook(); public static readonly Harmony harmony = new Harmony(typeof(BestDressedPlugin).GetCustomAttributes(typeof(BepInPlugin), inherit: false).Cast<BepInPlugin>().First() .GUID); public void Awake() { harmony.PatchAll(); } private void OnDestroy() { harmony.UnpatchSelf(); } } } namespace BestDressed.Patches { [HarmonyPatch(typeof(Player), "Start")] public static class PlayerStartPatch { [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] private static void Postfix(Player __instance) { if ((Object)(object)__instance == (Object)null) { return; } if ((Object)(object)BestDressedPlugin.CustomRuntime == (Object)null) { BestDressedPlugin.CustomRuntime = ModHelper.MakeAOC(BestDressedPlugin.replacementMap, ((Character)__instance).m_animator.runtimeAnimatorController); } if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } ZNetView nview = ((Character)__instance).m_nview; object obj; if (nview == null) { obj = null; } else { ZDO zdo = nview.m_zdo; obj = ((zdo != null) ? zdo.GetString("KGmodelchanged", "") : null); } string text = (string)obj; if (!string.IsNullOrWhiteSpace(text)) { ModHelper.ApplyModelOnPlayer(__instance, text); } ZNetView nview2 = ((Character)__instance).m_nview; float? obj2; if (nview2 == null) { obj2 = null; } else { ZDO zdo2 = nview2.m_zdo; obj2 = ((zdo2 != null) ? new float?(zdo2.GetFloat("KGmodelscale", 1f)) : null); } float? num = obj2; float valueOrDefault = num.GetValueOrDefault(1f); if (valueOrDefault != 1f) { ModHelper.ApplyScale(__instance, valueOrDefault); } if ((BestDressedPlugin.Humanoids != null && BestDressedPlugin.Humanoids.Count > 0) || (Object)(object)ZNetScene.instance == (Object)null) { return; } BestDressedPlugin.Humanoids = new Dictionary<string, string>(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { Humanoid component = prefab.GetComponent<Humanoid>(); if (!((Object)(object)component == (Object)null)) { string name = ((Object)prefab).name; string value = ((Character)component).m_name ?? name; BestDressedPlugin.Humanoids[name] = value; } } } BestDressedPlugin.OrderedHumanoids = BestDressedPlugin.Humanoids.OrderBy((KeyValuePair<string, string> pair) => Localization.instance.Localize(pair.Value)).ToList(); } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] public static class addcheats { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static ConsoleEvent <>9__0_1; public static ConsoleEvent <>9__0_2; public static ConsoleEvent <>9__0_3; public static ConsoleEvent <>9__0_4; public static ConsoleEvent <>9__0_5; public static ConsoleEvent <>9__0_6; public static ConsoleEvent <>9__0_7; public static ConsoleEvent <>9__0_8; [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_0(ConsoleEventArgs args) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (args.Length == 2) { if (BestDressedPlugin.Humanoids.ContainsKey(args[1])) { ((Character)Player.m_localPlayer).m_nview.m_zdo.Set("KGmodelchanged", args[1]); ZPackage val = new ZPackage(); val.Write(((Character)Player.m_localPlayer).GetZDOID()); val.Write(args[1]); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val }); args.Context.AddString("model changed! " + args[1]); } else { args.Context.AddString("invalid model"); } } else { args.Context.AddString("you must specify a model, use modellist to get the options"); } } [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_1(ConsoleEventArgs args) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) Player val = Player.m_localPlayer; if (args.Length >= 2) { <>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0 { targetName = args[1].ToLower() }; val = Player.GetAllPlayers().Find((Player p) => p.GetPlayerName().Replace(" ", "_").ToLower() == CS$<>8__locals0.targetName || p.GetPlayerName().ToLower() == CS$<>8__locals0.targetName); } if ((Object)(object)val == (Object)null) { args.Context.AddString("Player not found or not currently active."); return; } ((Character)val).m_nview.m_zdo.Set("KGmodelchanged", ""); ModHelper.ResetPlayerModel(val); ZPackage val2 = new ZPackage(); val2.Write(((Character)val).GetZDOID()); val2.Write(""); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val2 }); args.Context.AddString("Model cleared for " + val.GetPlayerName() + "."); } [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_2(ConsoleEventArgs args) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) Player val = Player.m_localPlayer; if (args.Length >= 2) { val = ModHelper.GetPlayerByName(args[1]); } if ((Object)(object)val == (Object)null) { args.Context.AddString("Player not found."); return; } ZPackage val2 = new ZPackage(); val2.Write(((Character)val).GetZDOID()); val2.Write(1f); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangesize", new object[1] { val2 }); args.Context.AddString("Scale reset to default (1.0) for " + val.GetPlayerName() + "."); } [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_3(ConsoleEventArgs args) { if (BestDressedPlugin.OrderedHumanoids == null) { args.Context.AddString("Humanoids not initialized yet."); return; } string text = "Models you can change to(hopefully): "; foreach (KeyValuePair<string, string> orderedHumanoid in BestDressedPlugin.OrderedHumanoids) { text = text + orderedHumanoid.Key + ", "; } args.Context.AddString(text); } [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_4(ConsoleEventArgs args) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) Player val = Player.m_localPlayer; if (args.Length >= 2) { val = ModHelper.GetPlayerByName(args[1]); } if ((Object)(object)val == (Object)null) { args.Context.AddString("Player not found."); return; } ((Character)val).m_nview.m_zdo.Set("KGmodelchanged", ""); ModHelper.ResetPlayerModel(val); ZPackage val2 = new ZPackage(); val2.Write(((Character)val).GetZDOID()); val2.Write(""); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val2 }); ((Character)val).m_nview.GetZDO().Set("KGmodelscale", 1f); args.Context.AddString("Full model and size reset applied for " + val.GetPlayerName() + "."); } [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_5(ConsoleEventArgs args) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { args.Context.AddString("Usage: /setmodel [model name] (optional: player name)"); return; } string text = args[1]; if (!BestDressedPlugin.Humanoids.ContainsKey(text)) { args.Context.AddString("Invalid model: " + text); return; } Player val = Player.m_localPlayer; if (args.Length >= 3) { <>c__DisplayClass0_1 CS$<>8__locals0 = new <>c__DisplayClass0_1 { targetName = args[2].ToLower() }; val = Player.GetAllPlayers().Find((Player p) => p.GetPlayerName().Replace(" ", "_").ToLower() == CS$<>8__locals0.targetName || p.GetPlayerName().ToLower() == CS$<>8__locals0.targetName); } if ((Object)(object)val == (Object)null) { args.Context.AddString("Player not found."); return; } ((Character)val).m_nview.m_zdo.Set("KGmodelchanged", text); ZPackage val2 = new ZPackage(); val2.Write(((Character)val).GetZDOID()); val2.Write(text); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val2 }); args.Context.AddString("Set " + val.GetPlayerName() + "'s model to " + text); } [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_6(ConsoleEventArgs args) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { args.Context.AddString("Usage: /setsize [number] [optional: name]"); return; } if (!float.TryParse(args[1], out var result)) { args.Context.AddString("Invalid scale number."); return; } Player val = Player.m_localPlayer; if (args.Length >= 3) { val = ModHelper.GetPlayerByName(args[2]); } if ((Object)(object)val != (Object)null) { ZPackage val2 = new ZPackage(); val2.Write(((Character)val).GetZDOID()); val2.Write(result); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangesize", new object[1] { val2 }); args.Context.AddString($"Set {val.GetPlayerName()} scale to {result}"); } else { args.Context.AddString("Player not found."); } } [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_7(ConsoleEventArgs args) { //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_00c2: 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_00e1: 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_00eb: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { return; } Player localPlayer = Player.m_localPlayer; Player playerByName = ModHelper.GetPlayerByName(args[1]); if (!((Object)(object)playerByName == (Object)null)) { if (!BestDressedPlugin.OGLook.OriginalGender.HasValue) { BestDressedPlugin.OGLook.OriginalGender = ((Character)localPlayer).m_nview.m_zdo.GetInt("ModelIndex", 0); BestDressedPlugin.OGLook.OriginalHair = ((Character)localPlayer).m_nview.m_zdo.GetString("HairItem", ""); BestDressedPlugin.OGLook.OriginalBeard = ((Character)localPlayer).m_nview.m_zdo.GetString("BeardItem", ""); BestDressedPlugin.OGLook.OriginalSkinColor = ((Character)localPlayer).m_nview.m_zdo.GetVec3("SkinColor", Vector3.one); BestDressedPlugin.OGLook.OriginalHairColor = ((Character)localPlayer).m_nview.m_zdo.GetVec3("HairColor", Vector3.one); } string @string = ((Character)playerByName).m_nview.m_zdo.GetString("KGmodelchanged", ""); ((Character)localPlayer).m_nview.m_zdo.Set("KGmodelchanged", @string); ((Character)localPlayer).m_nview.m_zdo.Set("ModelIndex", ((Character)playerByName).m_nview.m_zdo.GetInt("ModelIndex", 0)); ((Character)localPlayer).m_nview.m_zdo.Set("HairItem", ((Character)playerByName).m_nview.m_zdo.GetString("HairItem", "")); ((Character)localPlayer).m_nview.m_zdo.Set("BeardItem", ((Character)playerByName).m_nview.m_zdo.GetString("BeardItem", "")); ((Character)localPlayer).m_nview.m_zdo.Set("SkinColor", ((Character)playerByName).m_nview.m_zdo.GetVec3("SkinColor", Vector3.one)); ((Character)localPlayer).m_nview.m_zdo.Set("HairColor", ((Character)playerByName).m_nview.m_zdo.GetVec3("HairColor", Vector3.one)); if (string.IsNullOrEmpty(@string)) { ModHelper.ResetPlayerModel(localPlayer); } else { ModHelper.ApplyModelOnPlayer(localPlayer, @string); } ModHelper.ApplyScale(localPlayer, ((Character)playerByName).m_nview.m_zdo.GetFloat("KGmodelscale", 1f)); ModHelper.SyncModel(localPlayer, @string); args.Context.AddString("Disguised as " + playerByName.GetPlayerName() + "!"); } } [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] internal void <Postfix>b__0_8(ConsoleEventArgs args) { //IL_008f: 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) Player localPlayer = Player.m_localPlayer; if (BestDressedPlugin.OGLook.OriginalGender.HasValue) { ((Character)localPlayer).m_nview.m_zdo.Set("ModelIndex", BestDressedPlugin.OGLook.OriginalGender.Value); ((Character)localPlayer).m_nview.m_zdo.Set("HairItem", BestDressedPlugin.OGLook.OriginalHair); ((Character)localPlayer).m_nview.m_zdo.Set("BeardItem", BestDressedPlugin.OGLook.OriginalBeard); ((Character)localPlayer).m_nview.m_zdo.Set("SkinColor", BestDressedPlugin.OGLook.OriginalSkinColor); ((Character)localPlayer).m_nview.m_zdo.Set("HairColor", BestDressedPlugin.OGLook.OriginalHairColor); ((Character)localPlayer).m_nview.m_zdo.Set("KGmodelchanged", ""); ModHelper.ApplyScale(localPlayer, 1f); ModHelper.ResetPlayerModel(localPlayer); ModHelper.SyncModel(localPlayer, ""); BestDressedPlugin.OGLook.OriginalGender = null; args.Context.AddString("Appearance restored."); } } } [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public string targetName; internal bool <Postfix>b__9(Player p) { if (!(p.GetPlayerName().Replace(" ", "_").ToLower() == targetName)) { return p.GetPlayerName().ToLower() == targetName; } return true; } } [CompilerGenerated] private sealed class <>c__DisplayClass0_1 { public string targetName; internal bool <Postfix>b__10(Player p) { if (!(p.GetPlayerName().Replace(" ", "_").ToLower() == targetName)) { return p.GetPlayerName().ToLower() == targetName; } return true; } } private static void Postfix() { //IL_0032: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_006a: 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) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_00a2: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00d1: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0141: Expected O, but got Unknown //IL_0182: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_01ba: 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) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01f2: 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) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (args.Length == 2) { if (BestDressedPlugin.Humanoids.ContainsKey(args[1])) { ((Character)Player.m_localPlayer).m_nview.m_zdo.Set("KGmodelchanged", args[1]); ZPackage val20 = new ZPackage(); val20.Write(((Character)Player.m_localPlayer).GetZDOID()); val20.Write(args[1]); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val20 }); args.Context.AddString("model changed! " + args[1]); } else { args.Context.AddString("invalid model"); } } else { args.Context.AddString("you must specify a model, use modellist to get the options"); } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("modelchange", "", (ConsoleEvent)obj, true, false, false, true, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleEvent val2 = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) Player val18 = Player.m_localPlayer; if (args.Length >= 2) { string targetName2 = args[1].ToLower(); val18 = Player.GetAllPlayers().Find((Player p) => p.GetPlayerName().Replace(" ", "_").ToLower() == targetName2 || p.GetPlayerName().ToLower() == targetName2); } if ((Object)(object)val18 == (Object)null) { args.Context.AddString("Player not found or not currently active."); } else { ((Character)val18).m_nview.m_zdo.Set("KGmodelchanged", ""); ModHelper.ResetPlayerModel(val18); ZPackage val19 = new ZPackage(); val19.Write(((Character)val18).GetZDOID()); val19.Write(""); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val19 }); args.Context.AddString("Model cleared for " + val18.GetPlayerName() + "."); } }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } new ConsoleCommand("clearmodel", "(optional: name) Resets a character to the default model", (ConsoleEvent)obj2, true, false, false, true, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__0_2; if (obj3 == null) { ConsoleEvent val3 = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) Player val16 = Player.m_localPlayer; if (args.Length >= 2) { val16 = ModHelper.GetPlayerByName(args[1]); } if ((Object)(object)val16 == (Object)null) { args.Context.AddString("Player not found."); } else { ZPackage val17 = new ZPackage(); val17.Write(((Character)val16).GetZDOID()); val17.Write(1f); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangesize", new object[1] { val17 }); args.Context.AddString("Scale reset to default (1.0) for " + val16.GetPlayerName() + "."); } }; <>c.<>9__0_2 = val3; obj3 = (object)val3; } new ConsoleCommand("clearsize", "(optional: name) Resets a character's scale to default", (ConsoleEvent)obj3, true, false, false, true, false, (ConsoleOptionsFetcher)null, false, false, false); object obj4 = <>c.<>9__0_3; if (obj4 == null) { ConsoleEvent val4 = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { if (BestDressedPlugin.OrderedHumanoids == null) { args.Context.AddString("Humanoids not initialized yet."); } else { string text2 = "Models you can change to(hopefully): "; foreach (KeyValuePair<string, string> orderedHumanoid in BestDressedPlugin.OrderedHumanoids) { text2 = text2 + orderedHumanoid.Key + ", "; } args.Context.AddString(text2); } }; <>c.<>9__0_3 = val4; obj4 = (object)val4; } new ConsoleCommand("modellist", "", (ConsoleEvent)obj4, true, false, false, true, false, (ConsoleOptionsFetcher)null, false, false, false); object obj5 = <>c.<>9__0_4; if (obj5 == null) { ConsoleEvent val5 = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) Player val14 = Player.m_localPlayer; if (args.Length >= 2) { val14 = ModHelper.GetPlayerByName(args[1]); } if ((Object)(object)val14 == (Object)null) { args.Context.AddString("Player not found."); } else { ((Character)val14).m_nview.m_zdo.Set("KGmodelchanged", ""); ModHelper.ResetPlayerModel(val14); ZPackage val15 = new ZPackage(); val15.Write(((Character)val14).GetZDOID()); val15.Write(""); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val15 }); ((Character)val14).m_nview.GetZDO().Set("KGmodelscale", 1f); args.Context.AddString("Full model and size reset applied for " + val14.GetPlayerName() + "."); } }; <>c.<>9__0_4 = val5; obj5 = (object)val5; } new ConsoleCommand("modelreset", "(optional: name) Resets both model and size to default", (ConsoleEvent)obj5, true, false, false, true, false, (ConsoleOptionsFetcher)null, false, false, false); object obj6 = <>c.<>9__0_5; if (obj6 == null) { ConsoleEvent val6 = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { args.Context.AddString("Usage: /setmodel [model name] (optional: player name)"); } else { string text = args[1]; if (!BestDressedPlugin.Humanoids.ContainsKey(text)) { args.Context.AddString("Invalid model: " + text); } else { Player val12 = Player.m_localPlayer; if (args.Length >= 3) { string targetName = args[2].ToLower(); val12 = Player.GetAllPlayers().Find((Player p) => p.GetPlayerName().Replace(" ", "_").ToLower() == targetName || p.GetPlayerName().ToLower() == targetName); } if ((Object)(object)val12 == (Object)null) { args.Context.AddString("Player not found."); } else { ((Character)val12).m_nview.m_zdo.Set("KGmodelchanged", text); ZPackage val13 = new ZPackage(); val13.Write(((Character)val12).GetZDOID()); val13.Write(text); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val13 }); args.Context.AddString("Set " + val12.GetPlayerName() + "'s model to " + text); } } } }; <>c.<>9__0_5 = val6; obj6 = (object)val6; } new ConsoleCommand("setmodel", "[model] (optional: name)", (ConsoleEvent)obj6, true, false, false, true, false, (ConsoleOptionsFetcher)null, false, false, false); object obj7 = <>c.<>9__0_6; if (obj7 == null) { ConsoleEvent val7 = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) float result; if (args.Length < 2) { args.Context.AddString("Usage: /setsize [number] [optional: name]"); } else if (!float.TryParse(args[1], out result)) { args.Context.AddString("Invalid scale number."); } else { Player val10 = Player.m_localPlayer; if (args.Length >= 3) { val10 = ModHelper.GetPlayerByName(args[2]); } if ((Object)(object)val10 != (Object)null) { ZPackage val11 = new ZPackage(); val11.Write(((Character)val10).GetZDOID()); val11.Write(result); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangesize", new object[1] { val11 }); args.Context.AddString($"Set {val10.GetPlayerName()} scale to {result}"); } else { args.Context.AddString("Player not found."); } } }; <>c.<>9__0_6 = val7; obj7 = (object)val7; } new ConsoleCommand("setsize", "[scale] (optional: name)", (ConsoleEvent)obj7, true, false, false, true, false, (ConsoleOptionsFetcher)null, false, false, false); object obj8 = <>c.<>9__0_7; if (obj8 == null) { ConsoleEvent val8 = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_00c2: 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_00e1: 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_00eb: Unknown result type (might be due to invalid IL or missing references) if (args.Length >= 2) { Player localPlayer2 = Player.m_localPlayer; Player playerByName = ModHelper.GetPlayerByName(args[1]); if (!((Object)(object)playerByName == (Object)null)) { if (!BestDressedPlugin.OGLook.OriginalGender.HasValue) { BestDressedPlugin.OGLook.OriginalGender = ((Character)localPlayer2).m_nview.m_zdo.GetInt("ModelIndex", 0); BestDressedPlugin.OGLook.OriginalHair = ((Character)localPlayer2).m_nview.m_zdo.GetString("HairItem", ""); BestDressedPlugin.OGLook.OriginalBeard = ((Character)localPlayer2).m_nview.m_zdo.GetString("BeardItem", ""); BestDressedPlugin.OGLook.OriginalSkinColor = ((Character)localPlayer2).m_nview.m_zdo.GetVec3("SkinColor", Vector3.one); BestDressedPlugin.OGLook.OriginalHairColor = ((Character)localPlayer2).m_nview.m_zdo.GetVec3("HairColor", Vector3.one); } string @string = ((Character)playerByName).m_nview.m_zdo.GetString("KGmodelchanged", ""); ((Character)localPlayer2).m_nview.m_zdo.Set("KGmodelchanged", @string); ((Character)localPlayer2).m_nview.m_zdo.Set("ModelIndex", ((Character)playerByName).m_nview.m_zdo.GetInt("ModelIndex", 0)); ((Character)localPlayer2).m_nview.m_zdo.Set("HairItem", ((Character)playerByName).m_nview.m_zdo.GetString("HairItem", "")); ((Character)localPlayer2).m_nview.m_zdo.Set("BeardItem", ((Character)playerByName).m_nview.m_zdo.GetString("BeardItem", "")); ((Character)localPlayer2).m_nview.m_zdo.Set("SkinColor", ((Character)playerByName).m_nview.m_zdo.GetVec3("SkinColor", Vector3.one)); ((Character)localPlayer2).m_nview.m_zdo.Set("HairColor", ((Character)playerByName).m_nview.m_zdo.GetVec3("HairColor", Vector3.one)); if (string.IsNullOrEmpty(@string)) { ModHelper.ResetPlayerModel(localPlayer2); } else { ModHelper.ApplyModelOnPlayer(localPlayer2, @string); } ModHelper.ApplyScale(localPlayer2, ((Character)playerByName).m_nview.m_zdo.GetFloat("KGmodelscale", 1f)); ModHelper.SyncModel(localPlayer2, @string); args.Context.AddString("Disguised as " + playerByName.GetPlayerName() + "!"); } } }; <>c.<>9__0_7 = val8; obj8 = (object)val8; } new ConsoleCommand("doppelganger", "[name]", (ConsoleEvent)obj8, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj9 = <>c.<>9__0_8; if (obj9 == null) { ConsoleEvent val9 = [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] (ConsoleEventArgs args) => { //IL_008f: 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) Player localPlayer = Player.m_localPlayer; if (BestDressedPlugin.OGLook.OriginalGender.HasValue) { ((Character)localPlayer).m_nview.m_zdo.Set("ModelIndex", BestDressedPlugin.OGLook.OriginalGender.Value); ((Character)localPlayer).m_nview.m_zdo.Set("HairItem", BestDressedPlugin.OGLook.OriginalHair); ((Character)localPlayer).m_nview.m_zdo.Set("BeardItem", BestDressedPlugin.OGLook.OriginalBeard); ((Character)localPlayer).m_nview.m_zdo.Set("SkinColor", BestDressedPlugin.OGLook.OriginalSkinColor); ((Character)localPlayer).m_nview.m_zdo.Set("HairColor", BestDressedPlugin.OGLook.OriginalHairColor); ((Character)localPlayer).m_nview.m_zdo.Set("KGmodelchanged", ""); ModHelper.ApplyScale(localPlayer, 1f); ModHelper.ResetPlayerModel(localPlayer); ModHelper.SyncModel(localPlayer, ""); BestDressedPlugin.OGLook.OriginalGender = null; args.Context.AddString("Appearance restored."); } }; <>c.<>9__0_8 = val9; obj9 = (object)val9; } new ConsoleCommand("undoppelganger", "Restore original look", (ConsoleEvent)obj9, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class AddingZroutMethods { private static void Postfix() { ZRoutedRpc.instance.Register<ZPackage>("KGchangemodel", (Action<long, ZPackage>)ModHelper.PlayerChangedModel); ZRoutedRpc.instance.Register<ZPackage>("KGchangesize", (Action<long, ZPackage>)ModHelper.PlayerChangedSize); } } } namespace BestDressed.Helpers { [<88aceaad-7e9d-4b79-b728-8e2d9405707b>Nullable(0)] [<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(1)] public static class ModHelper { public static void ResetPlayerModel(Player p) { if ((Object)(object)p == (Object)null) { return; } Transform val = ((Component)p).transform.Find("NewVisual"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } Transform val2 = ((Component)p).transform.Find("Visual"); if (!((Object)(object)val2 == (Object)null)) { GameObject val3 = (((Character)p).m_visual = ((Component)val2).gameObject); val3.transform.SetSiblingIndex(0); val3.SetActive(true); Animator component = val3.GetComponent<Animator>(); if ((Object)(object)component != (Object)null) { ((Character)p).m_animator = component; ((Character)p).m_zanim.m_animator = component; } ((Humanoid)p).m_visEquipment.m_visual = val3; ((Humanoid)p).m_visEquipment.m_rightHand = Utils.FindChild(val3.transform, "RightHand_Attach", (IterativeSearchType)0); ((Humanoid)p).m_visEquipment.m_leftHand = Utils.FindChild(val3.transform, "LeftHand_Attach", (IterativeSearchType)0); ((Humanoid)p).m_visEquipment.m_helmet = Utils.FindChild(val3.transform, "Helmet_attach", (IterativeSearchType)0); FootStep component2 = ((Component)p).GetComponent<FootStep>(); if ((Object)(object)component2 != (Object)null) { component2.m_feet = (Transform[])(object)new Transform[2] { Utils.FindChild(val3.transform, "LeftFoot", (IterativeSearchType)0), Utils.FindChild(val3.transform, "RightFoot", (IterativeSearchType)0) }; } if ((Object)(object)((Character)p).m_collider != (Object)null) { ((Collider)((Character)p).m_collider).enabled = true; } } } private static void SetupAttachmentPoints(Player p, Transform root) { ((Humanoid)p).m_visEquipment.m_rightHand = FindFirst(root, "RightHand_Attach", "RightAttach", "RightHand", "r_hand", "mixamorig:RightHand"); ((Humanoid)p).m_visEquipment.m_leftHand = FindFirst(root, "LeftHand_Attach", "LeftAttach", "LeftHand", "l_hand", "mixamorig:LeftHand"); ((Humanoid)p).m_visEquipment.m_helmet = FindFirst(root, "Helmet_attach", "HelmetAttach", "Head", "head", "mixamorig:HeadTop_End"); } private static Transform FindFirst(Transform root, params string[] names) { foreach (string text in names) { Transform val = Utils.FindChild(root, text, (IterativeSearchType)0); if ((Object)(object)val != (Object)null) { return val; } } return null; } public static void ApplyModelOnPlayer(Player p, string changedModel) { //IL_008b: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null || string.IsNullOrWhiteSpace(changedModel) || (Object)(object)ZNetScene.instance == (Object)null) { return; } ResetPlayerModel(p); GameObject prefab = ZNetScene.instance.GetPrefab(changedModel); if ((Object)(object)prefab == (Object)null || (Object)(object)prefab.GetComponent<Humanoid>() == (Object)null) { return; } Animator componentInChildren = prefab.GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren == (Object)null) { return; } GameObject val = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject, ((Component)p).transform); val.transform.SetSiblingIndex(0); ((Object)val).name = "NewVisual"; val.transform.localPosition = Vector3.zero; ((Character)p).m_visual = val; Collider component = prefab.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Collider val2 = ModHelper.CopyComponent<Collider>(component, val); if ((Object)(object)val2 != (Object)null && (Object)(object)((Character)p).m_collider != (Object)null) { ((Component)val2).gameObject.layer = ((Component)((Character)p).m_collider).gameObject.layer; Transform val3 = Utils.FindChild(val.transform, "Armature", (IterativeSearchType)0); if ((Object)(object)val3 != (Object)null) { SkinnedMeshRenderer componentInChildren2 = val.GetComponentInChildren<SkinnedMeshRenderer>(); if ((Object)(object)componentInChildren2 != (Object)null) { Vector3 localScale = val3.localScale; Bounds bounds = componentInChildren2.sharedMesh.bounds; Vector3 val4 = Vector3.Scale(localScale, ((Bounds)(ref bounds)).size); if (((Vector3)(ref val4)).magnitude >= 12f) { val3.localScale /= 3.5f; CapsuleCollider val5 = (CapsuleCollider)(object)((val2 is CapsuleCollider) ? val2 : null); if (val5 != null) { val5.radius /= 3.5f; } } } } } } Animator component2 = val.GetComponent<Animator>(); if ((Object)(object)component2 != (Object)null) { component2.runtimeAnimatorController = BestDressedPlugin.CustomRuntime; ((Character)p).m_animator = component2; ((Character)p).m_zanim.m_animator = component2; } Transform val6 = ((Component)p).transform.Find("Visual"); if ((Object)(object)val6 != (Object)null) { ((Component)val6).gameObject.SetActive(false); } ((Humanoid)p).m_visEquipment.m_visual = val; SetupAttachmentPoints(p, val.transform); if ((Object)(object)((Character)p).m_collider != (Object)null) { ((Collider)((Character)p).m_collider).enabled = false; } FootStep component3 = ((Component)p).GetComponent<FootStep>(); if ((Object)(object)component3 != (Object)null) { component3.m_feet = (Transform[])(object)new Transform[2] { Utils.FindChild(val.transform, "LeftFoot", (IterativeSearchType)0), Utils.FindChild(val.transform, "RightFoot", (IterativeSearchType)0) }; } } public static void PlayerChangedModel(long sender, ZPackage pkg) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) if (pkg == null || (Object)(object)ZNetScene.instance == (Object)null) { return; } ZDOID val = pkg.ReadZDOID(); string changedModel = pkg.ReadString(); GameObject val2 = ZNetScene.instance.FindInstance(val); if (!((Object)(object)val2 == (Object)null)) { Player component = val2.GetComponent<Player>(); if (!((Object)(object)component == (Object)null)) { ApplyModelOnPlayer(component, changedModel); } } } public static T CopyComponent<[<88aceaad-7e9d-4b79-b728-8e2d9405707b>Nullable(0)] T>(T original, GameObject destination) where T : Component { Type type = ((object)original).GetType(); Component val = destination.AddComponent(type); try { BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo[] properties = type.GetProperties(bindingAttr); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.CanWrite) { propertyInfo.SetValue(val, propertyInfo.GetValue(original, null), null); } } FieldInfo[] fields = type.GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { fieldInfo.SetValue(val, fieldInfo.GetValue(original)); } } catch { } return (T)(object)((val is T) ? val : null); } public static RuntimeAnimatorController MakeAOC(Dictionary<string, string> replacement, RuntimeAnimatorController ORIGINAL) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown AnimatorOverrideController val = new AnimatorOverrideController(ORIGINAL); List<KeyValuePair<AnimationClip, AnimationClip>> list = new List<KeyValuePair<AnimationClip, AnimationClip>>(); AnimationClip[] animationClips = ((RuntimeAnimatorController)val).animationClips; foreach (AnimationClip val2 in animationClips) { string name = ((Object)val2).name; if (replacement.ContainsKey(name)) { AnimationClip value = Object.Instantiate<AnimationClip>(BestDressedPlugin.ExternalAnimations[replacement[name]]); list.Add(new KeyValuePair<AnimationClip, AnimationClip>(val2, value)); } else { list.Add(new KeyValuePair<AnimationClip, AnimationClip>(val2, val2)); } } val.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)list); return (RuntimeAnimatorController)val; } public static Vector3 Scale(float x, float z, float y) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return SanityCheck(new Vector3(x, y, z)); } private static Vector3 SanityCheck(Vector3 scale) { //IL_0000: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0042: Unknown result type (might be due to invalid IL or missing references) if (scale.x == 0f) { scale.x = 1f; } if (scale.y == 0f) { scale.y = scale.x; } if (scale.z == 0f) { scale.z = scale.x; } return scale; } public static void ApplyScale(Player p, float scale) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) if (!((Object)(object)p == (Object)null) && !(scale <= 0.01f) && !((Object)(object)ZNetScene.instance == (Object)null)) { Vector3 localScale = Scale(scale, scale, scale); ((Character)p).m_nview.SetLocalScale(localScale); if ((Object)(object)((Humanoid)p).m_visEquipment != (Object)null) { ((Humanoid)p).m_visEquipment.UpdateVisuals(); } if (((Character)p).m_nview.IsOwner()) { ((Character)p).m_nview.GetZDO().Set("KGmodelscale", scale); } } } public static void PlayerChangedSize(long sender, ZPackage pkg) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) if (pkg == null || (Object)(object)ZNetScene.instance == (Object)null) { return; } ZDOID val = pkg.ReadZDOID(); float scale = pkg.ReadSingle(); GameObject val2 = ZNetScene.instance.FindInstance(val); if (!((Object)(object)val2 == (Object)null)) { Player component = val2.GetComponent<Player>(); if (!((Object)(object)component == (Object)null)) { ApplyScale(component, scale); } } } public static Player GetPlayerByName(string name) { return Player.GetAllPlayers().Find([<47964d35-c044-4d50-9b09-ecfb482a44a2>NullableContext(0)] (Player p) => p.GetPlayerName().Replace(" ", "_").ToLower() == name.ToLower() || p.GetPlayerName().ToLower() == name.ToLower()); } public static void SyncModel(Player p, string model) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(((Character)p).GetZDOID()); val.Write(model); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "KGchangemodel", new object[1] { val }); } } } namespace Microsoft.CodeAnalysis { [<95b8a7b1-0869-446c-8420-d4d8a0a7dc92>Embedded] [CompilerGenerated] internal sealed class <95b8a7b1-0869-446c-8420-d4d8a0a7dc92>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<95b8a7b1-0869-446c-8420-d4d8a0a7dc92>Embedded] [CompilerGenerated] internal sealed class <28677597-4e1e-4f1f-8995-7ea42666c4dc>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <28677597-4e1e-4f1f-8995-7ea42666c4dc>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <28677597-4e1e-4f1f-8995-7ea42666c4dc>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<95b8a7b1-0869-446c-8420-d4d8a0a7dc92>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContextAttribute : Attribute { public readonly byte Flag; public <0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [<95b8a7b1-0869-446c-8420-d4d8a0a7dc92>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 ServerSync { [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] [PublicAPI] internal abstract class OwnConfigEntryBase { [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] public object LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] [PublicAPI] internal class SyncedConfigEntry<[<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(2)] [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] internal abstract class CustomSyncedValueBase { public object LocalBaseValue; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(1)] public readonly string Identifier; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(1)] public readonly Type Type; private object boxedValue; protected bool localIsOwner; public readonly int Priority; public object BoxedValue { get { return boxedValue; } set { boxedValue = value; this.ValueChanged?.Invoke(); } } public event Action ValueChanged; [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] [PublicAPI] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] internal sealed class CustomSyncedValue<[<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] T> : CustomSyncedValueBase { public T Value { get { return (T)base.BoxedValue; } set { base.BoxedValue = value; } } public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0) : base(configSync, identifier, typeof(T), priority) { Value = value; } public void AssignLocalValue(T value) { if (localIsOwner) { Value = value; } else { LocalBaseValue = value; } } } internal class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ReadOnly = false; } [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] [PublicAPI] [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] internal class ConfigSync { [HarmonyPatch(typeof(ZRpc), "HandlePackage")] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] private static class SnatchCurrentlyHandlingRPC { [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] public static ZRpc currentRpc; [HarmonyPrefix] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [HarmonyPatch(typeof(ZNet), "Awake")] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] internal static class RegisterRPCPatch { [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] [HarmonyPostfix] private static void Postfix(ZNet __instance) { isServer = __instance.IsServer(); foreach (ConfigSync configSync2 in configSyncs) { ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync); if (isServer) { configSync2.InitialSyncDone = true; Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections")); } } if (isServer) { ((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges()); } [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) { ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1] { new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = isAdmin } }); ConfigSync configSync = configSyncs.First(); if (configSync != null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package)); } } [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] static IEnumerator WatchAdminListChanges() { MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); List<string> CurrentList = new List<string>(adminList.GetList()); while (true) { yield return (object)new WaitForSeconds(30f); if (!adminList.GetList().SequenceEqual(CurrentList)) { CurrentList = new List<string>(adminList.GetList()); List<ZNetPeer> adminPeer = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p) { string hostName = p.m_rpc.GetSocket().GetHostName(); return ((object)listContainsId == null) ? adminList.Contains(hostName) : ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName })); }).ToList(); List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList(); SendAdmin(nonAdminPeer, isAdmin: false); SendAdmin(adminPeer, isAdmin: true); } } } } } [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class RegisterClientRPCPatch { [HarmonyPostfix] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] private static void Postfix(ZNet __instance, ZNetPeer peer) { if (__instance.IsServer()) { return; } foreach (ConfigSync configSync in configSyncs) { peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync); } } } [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] private class ParsedConfigs { [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<OwnConfigEntryBase, object> configValues = new Dictionary<OwnConfigEntryBase, object>(); [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 1, 1, 2 })] public readonly Dictionary<CustomSyncedValueBase, object> customValues = new Dictionary<CustomSyncedValueBase, object>(); } [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Shutdown")] private class ResetConfigsOnShutdown { [HarmonyPostfix] private static void Postfix() { ProcessingServerUpdate = true; foreach (ConfigSync configSync in configSyncs) { configSync.resetConfigsFromServer(); configSync.IsSourceOfTruth = true; configSync.InitialSyncDone = false; } ProcessingServerUpdate = false; } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] private class SendConfigsAfterLogin { [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] private class BufferingSocket : ISocket { public volatile bool finished = false; public volatile int versionMatchQueued = -1; public readonly List<ZPackage> Package = new List<ZPackage>(); public readonly ISocket Original; public BufferingSocket(ISocket original) { Original = original; } public bool IsConnected() { return Original.IsConnected(); } public ZPackage Recv() { return Original.Recv(); } public int GetSendQueueSize() { return Original.GetSendQueueSize(); } public int GetCurrentSendRate() { return Original.GetCurrentSendRate(); } public bool IsHost() { return Original.IsHost(); } public void Dispose() { Original.Dispose(); } public bool GotNewData() { return Original.GotNewData(); } public void Close() { Original.Close(); } public string GetEndPointString() { return Original.GetEndPointString(); } public void GetAndResetStats(out int totalSent, out int totalRecv) { Original.GetAndResetStats(ref totalSent, ref totalRecv); } public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec) { Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec); } public ISocket Accept() { return Original.Accept(); } public int GetHostPort() { return Original.GetHostPort(); } public bool Flush() { return Original.Flush(); } public string GetHostName() { return Original.GetHostName(); } public void VersionMatch() { if (finished) { Original.VersionMatch(); } else { versionMatchQueued = Package.Count; } } public void Send(ZPackage pkg) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown int pos = pkg.GetPos(); pkg.SetPos(0); int num = pkg.ReadInt(); if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished) { ZPackage val = new ZPackage(pkg.GetArray()); val.SetPos(pos); Package.Add(val); } else { pkg.SetPos(pos); Original.Send(pkg); } } } [HarmonyPriority(800)] [HarmonyPrefix] private static void Prefix([<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 2, 1, 1 })] ref Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 if (__instance.IsServer()) { BufferingSocket value = new BufferingSocket(rpc.GetSocket()); AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value); object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (val != null && (int)ZNet.m_onlineBackend > 0) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value); } if (__state == null) { __state = new Dictionary<Assembly, BufferingSocket>(); } __state[Assembly.GetExecutingAssembly()] = value; } } [HarmonyPostfix] private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc) { ZNetPeer peer; if (__instance.IsServer()) { object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null); if (peer == null) { SendBufferedData(); } else { ((MonoBehaviour)__instance).StartCoroutine(sendAsync()); } } void SendBufferedData() { if (rpc.GetSocket() is BufferingSocket bufferingSocket) { AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, bufferingSocket.Original); object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc }); ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null); if (val != null) { AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original); } } BufferingSocket bufferingSocket2 = __state[Assembly.GetExecutingAssembly()]; bufferingSocket2.finished = true; for (int i = 0; i < bufferingSocket2.Package.Count; i++) { if (i == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } bufferingSocket2.Original.Send(bufferingSocket2.Package[i]); } if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued) { bufferingSocket2.Original.VersionMatch(); } } IEnumerator sendAsync() { foreach (ConfigSync configSync in configSyncs) { List<PackageEntry> entries = new List<PackageEntry>(); if (configSync.CurrentVersion != null) { entries.Add(new PackageEntry { section = "Internal", key = "serverversion", type = typeof(string), value = configSync.CurrentVersion }); } MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); entries.Add(new PackageEntry { section = "Internal", key = "lockexempt", type = typeof(bool), value = (((object)listContainsId == null) ? ((object)adminList.Contains(rpc.GetSocket().GetHostName())) : listContainsId.Invoke(ZNet.instance, new object[2] { adminList, rpc.GetSocket().GetHostName() })) }); ZPackage package = ConfigsToPackage(configSync.allConfigs.Select([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false); yield return ((MonoBehaviour)__instance).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package)); } SendBufferedData(); } } } [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] private class PackageEntry { public string section = null; public string key = null; public Type type = null; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] public object value; } [HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] private static class PreventSavingServerInfo { [HarmonyPrefix] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] private static bool Prefix(ConfigEntryBase __instance, ref string __result) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || isWritableConfig(ownConfigEntryBase)) { return true; } __result = TomlTypeConverter.ConvertToString(ownConfigEntryBase.LocalBaseValue, __instance.SettingType); return false; } } [HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] private static class PreventConfigRereadChangingValues { [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] [HarmonyPrefix] private static bool Prefix(ConfigEntryBase __instance, string value) { OwnConfigEntryBase ownConfigEntryBase = configData(__instance); if (ownConfigEntryBase == null || ownConfigEntryBase.LocalBaseValue == null) { return true; } try { ownConfigEntryBase.LocalBaseValue = TomlTypeConverter.ConvertToValue(value, __instance.SettingType); } catch (Exception ex) { Debug.LogWarning((object)$"Config value of setting \"{__instance.Definition}\" could not be parsed and will be ignored. Reason: {ex.Message}; Value: {value}"); } return false; } } [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] private class InvalidDeserializationTypeException : Exception { public string expected = null; public string received = null; public string field = ""; } public static bool ProcessingServerUpdate; public readonly string Name; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] public string DisplayName; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] public string CurrentVersion; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] public string MinimumRequiredVersion; public bool ModRequired = false; private bool? forceConfigLocking; private bool isSourceOfTruth = true; private static readonly HashSet<ConfigSync> configSyncs; private readonly HashSet<OwnConfigEntryBase> allConfigs = new HashSet<OwnConfigEntryBase>(); private HashSet<CustomSyncedValueBase> allCustomValues = new HashSet<CustomSyncedValueBase>(); private static bool isServer; private static bool lockExempt; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private OwnConfigEntryBase lockedConfig = null; private const byte PARTIAL_CONFIGS = 1; private const byte FRAGMENTED_CONFIG = 2; private const byte COMPRESSED_CONFIG = 4; private readonly Dictionary<string, SortedDictionary<int, byte[]>> configValueCache = new Dictionary<string, SortedDictionary<int, byte[]>>(); [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 1, 0, 1 })] private readonly List<KeyValuePair<long, string>> cacheExpirations = new List<KeyValuePair<long, string>>(); private static long packageCounter; public bool IsLocked { get { bool? flag = forceConfigLocking; bool num; if (!flag.HasValue) { if (lockedConfig == null) { goto IL_0052; } num = ((IConvertible)lockedConfig.BaseConfig.BoxedValue).ToInt32(CultureInfo.InvariantCulture) != 0; } else { num = flag.GetValueOrDefault(); } if (!num) { goto IL_0052; } int result = ((!lockExempt) ? 1 : 0); goto IL_0053; IL_0053: return (byte)result != 0; IL_0052: result = 0; goto IL_0053; } set { forceConfigLocking = value; } } public bool IsAdmin => lockExempt || isSourceOfTruth; public bool IsSourceOfTruth { get { return isSourceOfTruth; } private set { if (value != isSourceOfTruth) { isSourceOfTruth = value; this.SourceOfTruthChanged?.Invoke(value); } } } public bool InitialSyncDone { get; private set; } = false; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] [method: <0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(2)] [field: <28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] public event Action<bool> SourceOfTruthChanged; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] [method: <0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(2)] [field: <28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private event Action lockedConfigChanged; static ConfigSync() { ProcessingServerUpdate = false; configSyncs = new HashSet<ConfigSync>(); lockExempt = false; packageCounter = 0L; RuntimeHelpers.RunClassConstructor(typeof(VersionCheck).TypeHandle); } public ConfigSync(string name) { Name = name; configSyncs.Add(this); new VersionCheck(this); } public SyncedConfigEntry<T> AddConfigEntry<[<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] T>(ConfigEntry<T> configEntry) { OwnConfigEntryBase ownConfigEntryBase = configData((ConfigEntryBase)(object)configEntry); SyncedConfigEntry<T> syncedEntry = ownConfigEntryBase as SyncedConfigEntry<T>; if (syncedEntry == null) { syncedEntry = new SyncedConfigEntry<T>(configEntry); AccessTools.DeclaredField(typeof(ConfigDescription), "<Tags>k__BackingField").SetValue(((ConfigEntryBase)configEntry).Description, new object[1] { new ConfigurationManagerAttributes() }.Concat(((ConfigEntryBase)configEntry).Description.Tags ?? Array.Empty<object>()).Concat(new SyncedConfigEntry<T>[1] { syncedEntry }).ToArray()); configEntry.SettingChanged += [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (object _, EventArgs _) => { if (!ProcessingServerUpdate && syncedEntry.SynchronizedConfig) { Broadcast(ZRoutedRpc.Everybody, (ConfigEntryBase)configEntry); } }; allConfigs.Add(syncedEntry); } return syncedEntry; } public SyncedConfigEntry<T> AddLockingConfigEntry<[<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] T>(ConfigEntry<T> lockingConfig) where T : IConvertible { if (lockedConfig != null) { throw new Exception("Cannot initialize locking ConfigEntry twice"); } lockedConfig = AddConfigEntry<T>(lockingConfig); lockingConfig.SettingChanged += [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (object _, EventArgs _) => { this.lockedConfigChanged?.Invoke(); }; return (SyncedConfigEntry<T>)lockedConfig; } internal void AddCustomValue(CustomSyncedValueBase customValue) { if (allCustomValues.Select([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (CustomSyncedValueBase v) => v.Identifier).Concat(new string[1] { "serverversion" }).Contains(customValue.Identifier)) { throw new Exception("Cannot have multiple settings with the same name or with a reserved name (serverversion)"); } allCustomValues.Add(customValue); allCustomValues = new HashSet<CustomSyncedValueBase>(allCustomValues.OrderByDescending([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (CustomSyncedValueBase v) => v.Priority)); customValue.ValueChanged += delegate { if (!ProcessingServerUpdate) { Broadcast(ZRoutedRpc.Everybody, customValue); } }; } private void RPC_FromServerConfigSync(ZRpc rpc, ZPackage package) { lockedConfigChanged += serverLockedSettingChanged; IsSourceOfTruth = false; if (HandleConfigSyncRPC(0L, package, clientUpdate: false)) { InitialSyncDone = true; } } private void RPC_FromOtherClientConfigSync(long sender, ZPackage package) { HandleConfigSyncRPC(sender, package, clientUpdate: true); } private bool HandleConfigSyncRPC(long sender, ZPackage package, bool clientUpdate) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown try { if (isServer && IsLocked) { ZRpc currentRpc = SnatchCurrentlyHandlingRPC.currentRpc; object obj; if (currentRpc == null) { obj = null; } else { ISocket socket = currentRpc.GetSocket(); obj = ((socket != null) ? socket.GetHostName() : null); } string text = (string)obj; if (text != null) { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null); SyncedList val = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance); if (!(((object)methodInfo == null) ? val.Contains(text) : ((bool)methodInfo.Invoke(ZNet.instance, new object[2] { val, text })))) { return false; } } } cacheExpirations.RemoveAll(([<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 0, 1 })] KeyValuePair<long, string> kv) => { if (kv.Key < DateTimeOffset.Now.Ticks) { configValueCache.Remove(kv.Value); return true; } return false; }); byte b = package.ReadByte(); if ((b & 2u) != 0) { long num = package.ReadLong(); string text2 = sender.ToString() + num; if (!configValueCache.TryGetValue(text2, out var value)) { value = new SortedDictionary<int, byte[]>(); configValueCache[text2] = value; cacheExpirations.Add(new KeyValuePair<long, string>(DateTimeOffset.Now.AddSeconds(60.0).Ticks, text2)); } int key = package.ReadInt(); int num2 = package.ReadInt(); value.Add(key, package.ReadByteArray()); if (value.Count < num2) { return false; } configValueCache.Remove(text2); package = new ZPackage(value.Values.SelectMany([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (byte[] a) => a).ToArray()); b = package.ReadByte(); } ProcessingServerUpdate = true; if ((b & 4u) != 0) { byte[] buffer = package.ReadByteArray(); MemoryStream stream = new MemoryStream(buffer); MemoryStream memoryStream = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(stream, CompressionMode.Decompress)) { deflateStream.CopyTo(memoryStream); } package = new ZPackage(memoryStream.ToArray()); b = package.ReadByte(); } if ((b & 1) == 0) { resetConfigsFromServer(); } ParsedConfigs parsedConfigs = ReadConfigsFromPackage(package); ConfigFile val2 = null; bool saveOnConfigSet = false; foreach (KeyValuePair<OwnConfigEntryBase, object> configValue in parsedConfigs.configValues) { if (!isServer && configValue.Key.LocalBaseValue == null) { configValue.Key.LocalBaseValue = configValue.Key.BaseConfig.BoxedValue; } if (val2 == null) { val2 = configValue.Key.BaseConfig.ConfigFile; saveOnConfigSet = val2.SaveOnConfigSet; val2.SaveOnConfigSet = false; } configValue.Key.BaseConfig.BoxedValue = configValue.Value; } if (val2 != null) { val2.SaveOnConfigSet = saveOnConfigSet; } foreach (KeyValuePair<CustomSyncedValueBase, object> customValue in parsedConfigs.customValues) { if (!isServer) { CustomSyncedValueBase key2 = customValue.Key; if (key2.LocalBaseValue == null) { key2.LocalBaseValue = customValue.Key.BoxedValue; } } customValue.Key.BoxedValue = customValue.Value; } Debug.Log((object)string.Format("Received {0} configs and {1} custom values from {2} for mod {3}", parsedConfigs.configValues.Count, parsedConfigs.customValues.Count, (isServer || clientUpdate) ? $"client {sender}" : "the server", DisplayName ?? Name)); if (!isServer) { serverLockedSettingChanged(); } return true; } finally { ProcessingServerUpdate = false; } } private ParsedConfigs ReadConfigsFromPackage(ZPackage package) { ParsedConfigs parsedConfigs = new ParsedConfigs(); Dictionary<string, OwnConfigEntryBase> dictionary = allConfigs.Where([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (OwnConfigEntryBase c) => c.SynchronizedConfig).ToDictionary([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (OwnConfigEntryBase c) => c.BaseConfig.Definition.Section + "_" + c.BaseConfig.Definition.Key, [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (OwnConfigEntryBase c) => c); Dictionary<string, CustomSyncedValueBase> dictionary2 = allCustomValues.ToDictionary([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (CustomSyncedValueBase c) => c.Identifier, [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (CustomSyncedValueBase c) => c); int num = package.ReadInt(); for (int i = 0; i < num; i++) { string text = package.ReadString(); string text2 = package.ReadString(); string text3 = package.ReadString(); Type type = Type.GetType(text3); if (text3 == "" || type != null) { object obj; try { obj = ((text3 == "") ? null : ReadValueWithTypeFromZPackage(package, type)); } catch (InvalidDeserializationTypeException ex) { Debug.LogWarning((object)("Got unexpected struct internal type " + ex.received + " for field " + ex.field + " struct " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + ex.expected)); continue; } OwnConfigEntryBase value2; if (text == "Internal") { CustomSyncedValueBase value; if (text2 == "serverversion") { if (obj?.ToString() != CurrentVersion) { Debug.LogWarning((object)("Received server version is not equal: server version = " + (obj?.ToString() ?? "null") + "; local version = " + (CurrentVersion ?? "unknown"))); } } else if (text2 == "lockexempt") { if (obj is bool flag) { lockExempt = flag; } } else if (dictionary2.TryGetValue(text2, out value)) { if ((text3 == "" && (!value.Type.IsValueType || Nullable.GetUnderlyingType(value.Type) != null)) || GetZPackageTypeString(value.Type) == text3) { parsedConfigs.customValues[value] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for internal value " + text2 + " for mod " + (DisplayName ?? Name) + ", expecting " + value.Type.AssemblyQualifiedName)); } } else if (dictionary.TryGetValue(text + "_" + text2, out value2)) { Type type2 = configType(value2.BaseConfig); if ((text3 == "" && (!type2.IsValueType || Nullable.GetUnderlyingType(type2) != null)) || GetZPackageTypeString(type2) == text3) { parsedConfigs.configValues[value2] = obj; continue; } Debug.LogWarning((object)("Got unexpected type " + text3 + " for " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ", expecting " + type2.AssemblyQualifiedName)); } else { Debug.LogWarning((object)("Received unknown config entry " + text2 + " in section " + text + " for mod " + (DisplayName ?? Name) + ". This may happen if client and server versions of the mod do not match.")); } continue; } Debug.LogWarning((object)("Got invalid type " + text3 + ", abort reading of received configs")); return new ParsedConfigs(); } return parsedConfigs; } private static bool isWritableConfig(OwnConfigEntryBase config) { ConfigSync configSync = configSyncs.FirstOrDefault([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (ConfigSync cs) => cs.allConfigs.Contains(config)); if (configSync == null) { return true; } return configSync.IsSourceOfTruth || !config.SynchronizedConfig || config.LocalBaseValue == null || (!configSync.IsLocked && (config != configSync.lockedConfig || lockExempt)); } private void serverLockedSettingChanged() { foreach (OwnConfigEntryBase allConfig in allConfigs) { configAttribute<ConfigurationManagerAttributes>(allConfig.BaseConfig).ReadOnly = !isWritableConfig(allConfig); } } private void resetConfigsFromServer() { ConfigFile val = null; bool saveOnConfigSet = false; foreach (OwnConfigEntryBase item in allConfigs.Where([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (OwnConfigEntryBase config) => config.LocalBaseValue != null)) { if (val == null) { val = item.BaseConfig.ConfigFile; saveOnConfigSet = val.SaveOnConfigSet; val.SaveOnConfigSet = false; } item.BaseConfig.BoxedValue = item.LocalBaseValue; item.LocalBaseValue = null; } if (val != null) { val.SaveOnConfigSet = saveOnConfigSet; } foreach (CustomSyncedValueBase item2 in allCustomValues.Where([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (CustomSyncedValueBase config) => config.LocalBaseValue != null)) { item2.BoxedValue = item2.LocalBaseValue; item2.LocalBaseValue = null; } lockedConfigChanged -= serverLockedSettingChanged; serverLockedSettingChanged(); } private IEnumerator<bool> distributeConfigToPeers(ZNetPeer peer, ZPackage package) { ZRoutedRpc rpc = ZRoutedRpc.instance; if (rpc == null) { yield break; } byte[] data = package.GetArray(); if (data != null && data.LongLength > 250000) { int fragments = (int)(1 + (data.LongLength - 1) / 250000); long packageIdentifier = ++packageCounter; int fragment = 0; while (fragment < fragments) { foreach (bool item in waitForQueue()) { yield return item; } if (peer.m_socket.IsConnected()) { ZPackage fragmentedPackage = new ZPackage(); fragmentedPackage.Write((byte)2); fragmentedPackage.Write(packageIdentifier); fragmentedPackage.Write(fragment); fragmentedPackage.Write(fragments); fragmentedPackage.Write(data.Skip(250000 * fragment).Take(250000).ToArray()); SendPackage(fragmentedPackage); if (fragment != fragments - 1) { yield return true; } int num = fragment + 1; fragment = num; continue; } break; } yield break; } foreach (bool item2 in waitForQueue()) { yield return item2; } SendPackage(package); void SendPackage(ZPackage pkg) { string text = Name + " ConfigSync"; if (isServer) { peer.m_rpc.Invoke(text, new object[1] { pkg }); } else { rpc.InvokeRoutedRPC(peer.m_server ? 0 : peer.m_uid, text, new object[1] { pkg }); } } IEnumerable<bool> waitForQueue() { float timeout = Time.time + 30f; while (peer.m_socket.GetSendQueueSize() > 20000) { if (Time.time > timeout) { Debug.Log((object)$"Disconnecting {peer.m_uid} after 30 seconds config sending timeout"); peer.m_rpc.Invoke("Error", new object[1] { (object)(ConnectionStatus)5 }); ZNet.instance.Disconnect(peer); break; } yield return false; } } } private IEnumerator sendZPackage(long target, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return Enumerable.Empty<object>().GetEnumerator(); } List<ZNetPeer> list = (List<ZNetPeer>)AccessTools.DeclaredField(typeof(ZRoutedRpc), "m_peers").GetValue(ZRoutedRpc.instance); if (target != ZRoutedRpc.Everybody) { list = list.Where([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (ZNetPeer p) => p.m_uid == target).ToList(); } return sendZPackage(list, package); } private IEnumerator sendZPackage(List<ZNetPeer> peers, ZPackage package) { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { yield break; } byte[] rawData = package.GetArray(); if (rawData != null && rawData.LongLength > 10000) { ZPackage compressedPackage = new ZPackage(); compressedPackage.Write((byte)4); MemoryStream output = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(output, CompressionLevel.Optimal)) { deflateStream.Write(rawData, 0, rawData.Length); } compressedPackage.Write(output.ToArray()); package = compressedPackage; } List<IEnumerator<bool>> writers = (from peer in peers where peer.IsReady() select peer into p select distributeConfigToPeers(p, package)).ToList(); writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); while (writers.Count > 0) { yield return null; writers.RemoveAll((IEnumerator<bool> writer) => !writer.MoveNext()); } } private void Broadcast(long target, params ConfigEntryBase[] configs) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(configs); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } private void Broadcast(long target, params CustomSyncedValueBase[] customValues) { if (!IsLocked || isServer) { ZPackage package = ConfigsToPackage(null, customValues); ZNet instance = ZNet.instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(sendZPackage(target, package)); } } } [return: <28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private static OwnConfigEntryBase configData(ConfigEntryBase config) { return config.Description.Tags?.OfType<OwnConfigEntryBase>().SingleOrDefault(); } [return: <28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 2, 1 })] public static SyncedConfigEntry<T> ConfigData<[<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] T>(ConfigEntry<T> config) { return ((ConfigEntryBase)config).Description.Tags?.OfType<SyncedConfigEntry<T>>().SingleOrDefault(); } private static T configAttribute<[<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] T>(ConfigEntryBase config) { return config.Description.Tags.OfType<T>().First(); } private static Type configType(ConfigEntryBase config) { return configType(config.SettingType); } private static Type configType(Type type) { return type.IsEnum ? Enum.GetUnderlyingType(type) : type; } private static ZPackage ConfigsToPackage([<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 2, 1 })] IEnumerable<ConfigEntryBase> configs = null, [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 2, 1 })] IEnumerable<CustomSyncedValueBase> customValues = null, [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 2, 1 })] IEnumerable<PackageEntry> packageEntries = null, bool partial = true) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown List<ConfigEntryBase> list = configs?.Where([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (ConfigEntryBase config) => configData(config).SynchronizedConfig).ToList() ?? new List<ConfigEntryBase>(); List<CustomSyncedValueBase> list2 = customValues?.ToList() ?? new List<CustomSyncedValueBase>(); ZPackage val = new ZPackage(); val.Write((byte)(partial ? 1 : 0)); val.Write(list.Count + list2.Count + (packageEntries?.Count() ?? 0)); foreach (PackageEntry item in packageEntries ?? Array.Empty<PackageEntry>()) { AddEntryToPackage(val, item); } foreach (CustomSyncedValueBase item2 in list2) { AddEntryToPackage(val, new PackageEntry { section = "Internal", key = item2.Identifier, type = item2.Type, value = item2.BoxedValue }); } foreach (ConfigEntryBase item3 in list) { AddEntryToPackage(val, new PackageEntry { section = item3.Definition.Section, key = item3.Definition.Key, type = configType(item3), value = item3.BoxedValue }); } return val; } private static void AddEntryToPackage(ZPackage package, PackageEntry entry) { package.Write(entry.section); package.Write(entry.key); package.Write((entry.value == null) ? "" : GetZPackageTypeString(entry.type)); AddValueToZPackage(package, entry.value); } private static string GetZPackageTypeString(Type type) { return type.AssemblyQualifiedName; } private static void AddValueToZPackage(ZPackage package, [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] object value) { Type type = value?.GetType(); if (value is Enum) { value = ((IConvertible)value).ToType(Enum.GetUnderlyingType(value.GetType()), CultureInfo.InvariantCulture); } else { if (value is ICollection collection) { package.Write(collection.Count); { foreach (object item in collection) { AddValueToZPackage(package, item); } return; } } if ((object)type != null && type.IsValueType && !type.IsPrimitive) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); package.Write(fields.Length); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { package.Write(GetZPackageTypeString(fieldInfo.FieldType)); AddValueToZPackage(package, fieldInfo.GetValue(value)); } return; } } ZRpc.Serialize(new object[1] { value }, ref package); } private static object ReadValueWithTypeFromZPackage(ZPackage package, Type type) { if ((object)type != null && type.IsValueType && !type.IsPrimitive && !type.IsEnum) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int num = package.ReadInt(); if (num != fields.Length) { throw new InvalidDeserializationTypeException { received = $"(field count: {num})", expected = $"(field count: {fields.Length})" }; } object uninitializedObject = FormatterServices.GetUninitializedObject(type); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { string text = package.ReadString(); if (text != GetZPackageTypeString(fieldInfo.FieldType)) { throw new InvalidDeserializationTypeException { received = text, expected = GetZPackageTypeString(fieldInfo.FieldType), field = fieldInfo.Name }; } fieldInfo.SetValue(uninitializedObject, ReadValueWithTypeFromZPackage(package, fieldInfo.FieldType)); } return uninitializedObject; } if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<, >)) { int num2 = package.ReadInt(); IDictionary dictionary = (IDictionary)Activator.CreateInstance(type); Type type2 = typeof(KeyValuePair<, >).MakeGenericType(type.GenericTypeArguments); FieldInfo field = type2.GetField("key", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = type2.GetField("value", BindingFlags.Instance | BindingFlags.NonPublic); for (int j = 0; j < num2; j++) { object obj = ReadValueWithTypeFromZPackage(package, type2); dictionary.Add(field.GetValue(obj), field2.GetValue(obj)); } return dictionary; } if (type != typeof(List<string>) && type.IsGenericType) { Type type3 = typeof(ICollection<>).MakeGenericType(type.GenericTypeArguments[0]); if ((object)type3 != null && type3.IsAssignableFrom(type)) { int num3 = package.ReadInt(); object obj2 = Activator.CreateInstance(type); MethodInfo method = type3.GetMethod("Add"); for (int k = 0; k < num3; k++) { method.Invoke(obj2, new object[1] { ReadValueWithTypeFromZPackage(package, type.GenericTypeArguments[0]) }); } return obj2; } } ParameterInfo parameterInfo = (ParameterInfo)FormatterServices.GetUninitializedObject(typeof(ParameterInfo)); AccessTools.DeclaredField(typeof(ParameterInfo), "ClassImpl").SetValue(parameterInfo, type); List<object> source = new List<object>(); ZRpc.Deserialize(new ParameterInfo[2] { null, parameterInfo }, package, ref source); return source.First(); } } [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(0)] [PublicAPI] [HarmonyPatch] [<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(1)] internal class VersionCheck { private static readonly HashSet<VersionCheck> versionChecks; private static readonly Dictionary<string, string> notProcessedNames; public string Name; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private string displayName; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private string currentVersion; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private string minimumRequiredVersion; public bool ModRequired = true; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private string ReceivedCurrentVersion; [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private string ReceivedMinimumRequiredVersion; private readonly List<ZRpc> ValidatedClients = new List<ZRpc>(); [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] private ConfigSync ConfigSync; public string DisplayName { get { return displayName ?? Name; } set { displayName = value; } } public string CurrentVersion { get { return currentVersion ?? "0.0.0"; } set { currentVersion = value; } } public string MinimumRequiredVersion { get { return minimumRequiredVersion ?? (ModRequired ? CurrentVersion : "0.0.0"); } set { minimumRequiredVersion = value; } } private static void PatchServerSync() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown Patches patchInfo = PatchProcessor.GetPatchInfo((MethodBase)AccessTools.DeclaredMethod(typeof(ZNet), "Awake", (Type[])null, (Type[])null)); if (patchInfo != null && patchInfo.Postfixes.Count([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (Patch p) => p.PatchMethod.DeclaringType == typeof(ConfigSync.RegisterRPCPatch)) > 0) { return; } Harmony val = new Harmony("org.bepinex.helpers.ServerSync"); foreach (Type item in from t in typeof(ConfigSync).GetNestedTypes(BindingFlags.NonPublic).Concat(new Type[1] { typeof(VersionCheck) }) where t.IsClass select t) { val.PatchAll(item); } } static VersionCheck() { versionChecks = new HashSet<VersionCheck>(); notProcessedNames = new Dictionary<string, string>(); typeof(ThreadingHelper).GetMethod("StartSyncInvoke").Invoke(ThreadingHelper.Instance, new object[1] { new Action(PatchServerSync) }); } public VersionCheck(string name) { Name = name; ModRequired = true; versionChecks.Add(this); } public VersionCheck(ConfigSync configSync) { ConfigSync = configSync; Name = ConfigSync.Name; versionChecks.Add(this); } public void Initialize() { ReceivedCurrentVersion = null; ReceivedMinimumRequiredVersion = null; if (ConfigSync != null) { Name = ConfigSync.Name; DisplayName = ConfigSync.DisplayName; CurrentVersion = ConfigSync.CurrentVersion; MinimumRequiredVersion = ConfigSync.MinimumRequiredVersion; ModRequired = ConfigSync.ModRequired; } } private bool IsVersionOk() { if (ReceivedMinimumRequiredVersion == null || ReceivedCurrentVersion == null) { return !ModRequired; } bool flag = new System.Version(CurrentVersion) >= new System.Version(ReceivedMinimumRequiredVersion); bool flag2 = new System.Version(ReceivedCurrentVersion) >= new System.Version(MinimumRequiredVersion); return flag && flag2; } private string ErrorClient() { if (ReceivedMinimumRequiredVersion == null) { return DisplayName + " is not installed on the server."; } return (new System.Version(CurrentVersion) >= new System.Version(ReceivedMinimumRequiredVersion)) ? (DisplayName + " may not be higher than version " + ReceivedCurrentVersion + ". You have version " + CurrentVersion + ".") : (DisplayName + " needs to be at least version " + ReceivedMinimumRequiredVersion + ". You have version " + CurrentVersion + "."); } private string ErrorServer(ZRpc rpc) { return "Disconnect: The client (" + rpc.GetSocket().GetHostName() + ") doesn't have the correct " + DisplayName + " version " + MinimumRequiredVersion; } private string Error([<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(2)] ZRpc rpc = null) { return (rpc == null) ? ErrorClient() : ErrorServer(rpc); } private static VersionCheck[] GetFailedClient() { return versionChecks.Where([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (VersionCheck check) => !check.IsVersionOk()).ToArray(); } private static VersionCheck[] GetFailedServer(ZRpc rpc) { return versionChecks.Where([<0ddd9460-78db-4243-b9cf-4bd669ed711b>NullableContext(0)] (VersionCheck check) => check.ModRequired && !check.ValidatedClients.Contains(rpc)).ToArray(); } private static void Logout() { Game.instance.Logout(true, true); AccessTools.DeclaredField(typeof(ZNet), "m_connectionStatus").SetValue(null, (object)(ConnectionStatus)3); } private static void DisconnectClient(ZRpc rpc) { rpc.Invoke("Error", new object[1] { 3 }); } private static void CheckVersion(ZRpc rpc, ZPackage pkg) { CheckVersion(rpc, pkg, null); } private static void CheckVersion(ZRpc rpc, ZPackage pkg, [<28677597-4e1e-4f1f-8995-7ea42666c4dc>Nullable(new byte[] { 2, 1, 1 })] Action<ZRpc, ZPackage> original) { string text = pkg.ReadString(); string text2 = pkg.ReadString(); string text3 = pkg.ReadString(); b
files/plugins/ValheimRoleplay.dll
Decompiled a day 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.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Net; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using MessageRouter; using Microsoft.CodeAnalysis; using ServerSync; using SimpleJson; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; using ValheimRoleplay; using ValheimRoleplay.Data; using ValheimRoleplay.Helpers; using ValheimRoleplay.Patches; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ValheimRoleplay")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("ValheimRoleplay")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("2.1.2")] [assembly: AssemblyCompany("Arielle")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.2.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<0f55d190-8dd3-4ef8-9f52-bbe85c5ed529>Embedded] internal sealed class <0f55d190-8dd3-4ef8-9f52-bbe85c5ed529>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [<0f55d190-8dd3-4ef8-9f52-bbe85c5ed529>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <a8917c20-7ff1-455f-9f19-9daec886b40f>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <a8917c20-7ff1-455f-9f19-9daec886b40f>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <a8917c20-7ff1-455f-9f19-9daec886b40f>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<0f55d190-8dd3-4ef8-9f52-bbe85c5ed529>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <4713ac70-5c40-4c8e-abac-415a3e416205>NullableContextAttribute : Attribute { public readonly byte Flag; public <4713ac70-5c40-4c8e-abac-415a3e416205>NullableContextAttribute(byte P_0) { Flag = P_0; } } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public class EventBench { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(0)] [HarmonyPatch(typeof(CraftingStation), "Start")] private class RegisterEventBench { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] private static void Postfix(CraftingStation __instance) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (((component != null) ? component.GetPrefabName() : null) == PIECE_NAME && !EventStations.Contains(__instance)) { EventStations.Add(__instance); } } } [HarmonyPatch(typeof(CraftingStation), "OnDestroy")] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(0)] private class CraftingStation_Destroy { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] private static void Prefix(CraftingStation __instance) { EventStations.Remove(__instance); } } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(0)] [HarmonyPatch(typeof(Player), "Update")] public static class Player_Update_EventZone { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] private static void Postfix(Player __instance) { if ((Object)(object)__instance == (Object)null || !((Character)__instance).IsOwner()) { return; } checkTimer += Time.deltaTime; if (!(checkTimer < 0.25f)) { checkTimer = 0f; long playerID = __instance.GetPlayerID(); bool flag = IsInEventArea(__instance); if (!PlayerZoneState.TryGetValue(playerID, out var value)) { PlayerZoneState[playerID] = flag; } else if (flag != value) { PlayerZoneState[playerID] = flag; string text = (flag ? "You have entered an Event Zone" : "You have left the Event Zone"); ((Character)__instance).Message((MessageType)1, text, 0, (Sprite)null); } } } } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(0)] [HarmonyPatch(typeof(Humanoid))] public static class HammerPatches { [HarmonyPrefix] [HarmonyPatch("EquipItem")] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] private static bool EquipItem_Prefix(Humanoid __instance, ItemData item) { if (!PREVENT_EQUIP) { return true; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { if (IsAdmin(val)) { return true; } if (IsItemAllowedInEventArea(item)) { return true; } if (!IsInEventArea(val)) { return true; } ((Character)__instance).Message((MessageType)2, PLAYER_MASSAGE_BLOCKED_EQUIP, 0, (Sprite)null); return false; } return true; } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [HarmonyPatch(typeof(Player))] public static class PlayerPatches { [HarmonyPatch("TryPlacePiece")] [HarmonyPrefix] private static bool TryPlacePiece_Prefix(Player __instance, ref bool __result) { if (!PREVENT_BUILDING || IsAdmin(__instance) || !IsInEventArea(__instance)) { return true; } __result = false; ((Character)__instance).Message((MessageType)2, PLAYER_MASSAGE_BLOCKED_PLACE, 0, (Sprite)null); return false; } [HarmonyPrefix] [HarmonyPatch("RemovePiece")] private static bool RemovePiece_Prefix(Player __instance, ref bool __result) { if (!PREVENT_BUILDING || IsAdmin(__instance) || !IsInEventArea(__instance)) { return true; } __result = false; ((Character)__instance).Message((MessageType)2, PLAYER_MASSAGE_BLOCKED_REMOVE, 0, (Sprite)null); return false; } } private static readonly string PIECE_TO_CLONE = "piece_workbench"; private static readonly string PIECE_NAME = "piece_event_bench"; private static readonly string DISPLAY_NAME = "Event Bench"; private static readonly float RANGE = 200f; private static readonly bool PREVENT_BUILDING = true; private static readonly bool PREVENT_EQUIP = true; private static readonly List<CraftingStation> EventStations = new List<CraftingStation>(); private static readonly string PLAYER_MASSAGE_BLOCKED_PLACE = "$msg_nobuildzone"; private static readonly string PLAYER_MASSAGE_BLOCKED_REMOVE = "$msg_nobuildzone"; private static readonly string PLAYER_MASSAGE_BLOCKED_EQUIP = "You won't need this here"; private static readonly List<string> FORBIDDEN_ITEMS = new List<string>(); private static readonly List<string> FORBIDDEN_STRINGS = new List<string>(); private static readonly List<ItemType> FORBIDDEN_TYPES = new List<ItemType> { (ItemType)19 }; private static readonly Dictionary<long, bool> PlayerZoneState = new Dictionary<long, bool>(); private static float checkTimer = 0f; private static bool IsAdmin(Player player) { return ClientPatches.isAdmin(); } public static void OnVanillaPrefabsAvailable() { AddToPieceManager(); PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; } private static void AddToPieceManager() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //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_0045: 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_0054: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0151: 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_0171: 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) PieceConfig val = new PieceConfig(); val.Name = DISPLAY_NAME; val.PieceTable = PieceTables.Hammer; val.Category = PieceCategories.Misc; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "SledgeCheat", Amount = 1, Recover = false } }; PieceConfig val2 = val; CustomPiece val3 = new CustomPiece(PIECE_NAME, PIECE_TO_CLONE, val2); PieceManager.Instance.AddPiece(val3); GameObject piecePrefab = val3.PiecePrefab; WearNTear component = piecePrefab.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } GameObject prefab = PrefabManager.Instance.GetPrefab("StatueCorgi"); if (!((Object)(object)prefab != (Object)null)) { return; } foreach (Transform item in piecePrefab.transform) { Transform val4 = item; string text = ((Object)val4).name.ToLower(); if (text.Contains("visual") || text.Contains("new")) { Object.DestroyImmediate((Object)(object)((Component)val4).gameObject); } } GameObject obj = Object.Instantiate<GameObject>(prefab); ((Object)obj).name = "visual"; obj.transform.SetParent(piecePrefab.transform, false); obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one * 0.6f; CraftingStation component2 = piecePrefab.GetComponent<CraftingStation>(); component2.m_craftRequireRoof = false; component2.m_useDistance = 0f; component2.m_name = "Event Zone"; Collider[] componentsInChildren = obj.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } EffectArea componentInChildren = piecePrefab.GetComponentInChildren<EffectArea>(); if ((Object)(object)componentInChildren != (Object)null) { CapsuleCollider[] componentsInChildren2 = ((Component)componentInChildren).GetComponentsInChildren<CapsuleCollider>(); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].radius = RANGE; } } } private static bool IsInEventArea(Player player) { //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_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) Vector3 position = ((Component)player).transform.position; foreach (CraftingStation eventStation in EventStations) { if ((Object)(object)eventStation != (Object)null && Vector3.Distance(((Component)eventStation).transform.position, position) < RANGE) { return true; } } return false; } private static bool IsItemAllowedInEventArea(ItemData item) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) object obj; if (item == null) { obj = null; } else { GameObject dropPrefab = item.m_dropPrefab; obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); } string text = (string)obj; if (text == null || item.m_shared == null) { return true; } if (FORBIDDEN_TYPES.Contains(item.m_shared.m_itemType)) { return false; } if (FORBIDDEN_ITEMS.Contains(text)) { return false; } foreach (string fORBIDDEN_STRING in FORBIDDEN_STRINGS) { if (text.IndexOf(fORBIDDEN_STRING, StringComparison.OrdinalIgnoreCase) >= 0) { return false; } } return true; } } [HarmonyPatch(typeof(Character), "UpdateGroundContact")] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public class FallDamagePatch { [CompilerGenerated] private sealed class <Transpiler>d__2 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 0, 1 })] private IEnumerable<CodeInstruction> instructions; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 0, 1 })] public IEnumerable<CodeInstruction> <>3__instructions; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 0, 1 })] private IEnumerator<CodeInstruction> <>7__wrap1; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <Transpiler>d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; } if (<>7__wrap1.MoveNext()) { CodeInstruction current = <>7__wrap1.Current; if (CodeInstructionExtensions.Calls(current, ClampMethod)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)NewDamageMethod); <>1__state = 1; return true; } <>2__current = current; <>1__state = 2; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <Transpiler>d__2 <Transpiler>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <Transpiler>d__ = this; } else { <Transpiler>d__ = new <Transpiler>d__2(0); } <Transpiler>d__.instructions = <>3__instructions; return <Transpiler>d__; } [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } private static readonly MethodInfo ClampMethod = AccessTools.Method(typeof(Mathf), "Clamp01", (Type[])null, (Type[])null); private static readonly MethodInfo NewDamageMethod = AccessTools.Method(typeof(FallDamagePatch), "CalculateFallDamage", (Type[])null, (Type[])null); [IteratorStateMachine(typeof(<Transpiler>d__2))] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Transpiler>d__2(-2) { <>3__instructions = instructions }; } public static float CalculateFallDamage(float t) { float num = t * 16f + 4f; if (num <= 4f) { return 0f; } return Mathf.Pow(Mathf.Clamp01((num - 4f) / 52f), 1.5f) * 5f; } } namespace MessageRouter { [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static class RoutedRPCDataExtensions { public static void DeserializeFrom(this RoutedRPCData routedRpcData, ref ZPackage sourcePackage) { //IL_002a: 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) routedRpcData.m_msgID = sourcePackage.ReadLong(); routedRpcData.m_senderPeerID = sourcePackage.ReadLong(); routedRpcData.m_targetPeerID = sourcePackage.ReadLong(); routedRpcData.m_targetZDO = sourcePackage.ReadZDOID(); routedRpcData.m_methodHash = sourcePackage.ReadInt(); sourcePackage.ReadPackageTo(ref routedRpcData.m_parameters); } public static void Clear(this RoutedRPCData routedRpcData) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) routedRpcData.m_msgID = 0L; routedRpcData.m_senderPeerID = 0L; routedRpcData.m_targetPeerID = 0L; routedRpcData.m_targetZDO = default(ZDOID); routedRpcData.m_methodHash = 0; ZPackage parameters = routedRpcData.m_parameters; if (parameters != null) { parameters.Clear(); } } } public abstract class RpcMethodHandler { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public abstract bool Process(RoutedRPCData routedRpcData); } public static class ZPackageExtensions { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static void ReadPackageTo(this ZPackage sourcePackage, ref ZPackage targetPackage) { int num = sourcePackage.m_reader.ReadInt32(); targetPackage.m_writer.Flush(); targetPackage.m_stream.SetLength(num); targetPackage.m_stream.Position = 0L; sourcePackage.m_reader.Read(targetPackage.m_stream.GetBuffer(), 0, num); } } [HarmonyPatch(typeof(ZRoutedRpc))] internal static class ZRoutedRpcPatch { [HarmonyPrefix] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [HarmonyPatch("RPC_RoutedRPC")] private static bool RPC_RoutedRPCPrefix(ZRoutedRpc __instance, ZRpc rpc, ZPackage pkg) { if (__instance.m_server) { RoutedRpcManager.ProcessRoutedRPC(__instance, rpc, pkg); return false; } return true; } } [HarmonyPatch(typeof(ZNet))] internal static class ZNetPatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void StartPostfix() { RoutedRpcManager.SetupServerPeer(); } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static class RoutedRpcManager { public static readonly Dictionary<int, string> HashCodeToMethodNameCache = new Dictionary<int, string>(); private static readonly Dictionary<int, List<RpcMethodHandler>> _rpcMethodHandlers = new Dictionary<int, List<RpcMethodHandler>>(); private static readonly RoutedRPCData _routedRpcData = new RoutedRPCData(); private static long _serverPeerId = 0L; public static long ServerPeerId => _serverPeerId; public static void SetupServerPeer() { _serverPeerId = ZDOMan.s_instance.m_sessionID; } public static void RPC_ServerModerationLog(long sender, string json) { ZLog.Log((object)("[VRP] SERVER RECEIVED LOG: " + json)); if ((Object)(object)ZNet.instance != (Object)null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(Api.LogInsert(json)); } } public static void ServerModerationLog(string player, string steamId, string item, string action, string creator, string raw, int isAdmin = 0) { DbLog logEntry = new DbLog { p = player, s = steamId, i = item, a = action, c = creator, r = raw, m = isAdmin }; if ((Object)(object)ZNet.instance != (Object)null) { ((MonoBehaviour)ZNet.instance).StartCoroutine(Api.LogInsert(logEntry)); } } public static void AddHandler(string methodName, RpcMethodHandler handler) { int stableHashCode = StringExtensionMethods.GetStableHashCode(methodName); HashCodeToMethodNameCache[stableHashCode] = methodName; ServerModerationLog("server", "", "", "rpcmanager", "handler", $"Adding handler for {methodName} ({stableHashCode}): {handler.GetType().FullName}"); if (!_rpcMethodHandlers.TryGetValue(stableHashCode, out var value)) { value = new List<RpcMethodHandler>(); _rpcMethodHandlers[stableHashCode] = value; } value.Add(handler); } public static void ProcessRoutedRPC(ZRoutedRpc routedRpc, ZRpc rpc, ZPackage package) { _routedRpcData.DeserializeFrom(ref package); long targetPeerID = _routedRpcData.m_targetPeerID; long id = routedRpc.m_id; if (targetPeerID == id || targetPeerID == 0L) { routedRpc.HandleRoutedRPC(_routedRpcData); } if ((targetPeerID != id || targetPeerID == _serverPeerId) && ProcessHandlers(_routedRpcData)) { routedRpc.RouteRPC(_routedRpcData); } } public static bool ProcessHandlers(RoutedRPCData routedRpcData) { if (!_rpcMethodHandlers.TryGetValue(routedRpcData.m_methodHash, out var value)) { return true; } bool flag = true; foreach (RpcMethodHandler item in value) { flag &= item.Process(routedRpcData); } return flag; } public static string MethodHashToString(int methodHash) { if (HashCodeToMethodNameCache.TryGetValue(methodHash, out var value)) { return value; } return $"RPC_{methodHash}"; } } } namespace ValheimRoleplay { [Serializable] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public class DbLog { public string p { get; set; } = ""; public string s { get; set; } = ""; public int m { get; set; } public string i { get; set; } = ""; public string a { get; set; } = ""; public string b { get; set; } = ""; public string c { get; set; } = ""; public string r { get; set; } = ""; public string ToJson() { return $"{{\"p\":\"{p}\",\"s\":\"{s}\",\"m\":{m},\"i\":\"{i}\",\"a\":\"{a}\",\"b\":\"{b}\",\"c\":\"{c}\",\"r\":\"{Escape(r)}\"}}"; } private string Escape(string str) { return str?.Replace("\"", "\\\"") ?? ""; } } [Serializable] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public class DbPlayer { public string player { get; set; } } [Serializable] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public class DbWhitelist { public bool isAuthenticating; public int pid { get; set; } public int cid { get; set; } public string steamid { get; set; } public string charactername { get; set; } public bool isnew { get; set; } public bool permadeath { get; set; } public string season { get; set; } public int admincharacter { get; set; } } [Serializable] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public class DbWhitelistNew { public int pid { get; set; } public int cid { get; set; } public string steamid { get; set; } public string charName { get; set; } } [Serializable] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public class DbSkills { public string charactername { get; set; } public string skill { get; set; } public int cap { get; set; } } [Serializable] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public class DbPieces { public string itemName { get; set; } public string recipeName { get; set; } public string groups { get; set; } public int is_enabled { get; set; } public bool deleted { get; set; } } [Serializable] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public class DbGroup { public string charactername { get; set; } public string craftgroup { get; set; } public bool deleted { get; set; } } [Serializable] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public class DbRecipe { public string itemName { get; set; } public string recipeName { get; set; } public string groups { get; set; } public int is_enabled { get; set; } public bool deleted { get; set; } } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] internal class Api { [CompilerGenerated] private sealed class <LogInsert>d__1 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private object <>2__current; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public string json; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <LogInsert>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Invalid comparison between Unknown and I4 bool result; try { switch (<>1__state) { default: result = false; break; case 0: { <>1__state = -1; string text = "http://127.0.0.1:3333/logs/add"; <request>5__2 = new UnityWebRequest(text, "POST"); <>1__state = -3; byte[] bytes = Encoding.UTF8.GetBytes(json); <request>5__2.uploadHandler = (UploadHandler)new UploadHandlerRaw(bytes); <request>5__2.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); <request>5__2.SetRequestHeader("Content-Type", "application/json"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; result = true; break; } case 1: <>1__state = -3; if ((int)<request>5__2.result != 1) { ZLog.LogWarning((object)("[LogInsert Error]: " + <request>5__2.error + " | Response: " + <request>5__2.downloadHandler.text)); } result = false; <>m__Finally1(); break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<request>5__2 != null) { ((IDisposable)<request>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ServerGetGroups>d__5 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private object <>2__current; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <ServerGetGroups>d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; <request>5__2 = UnityWebRequest.Get("http://127.0.0.1:3333/groups/"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; if ((int)<request>5__2.result == 1) { DbGroup[] array = SimpleJson.DeserializeObject<DbGroup[]>(Encoding.UTF8.GetString(<request>5__2.downloadHandler.data)); if (array != null) { ServerPatches.groups.Clear(); DbGroup[] array2 = array; foreach (DbGroup item in array2) { ServerPatches.groups.Add(item); } ZLog.Log((object)$"[VRP] Server now has {ServerPatches.groups.Count} groups in memory."); } else { ZLog.LogError((object)"error groups json"); } } else { ZLog.LogError((object)"error in groups request"); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ServerGetPieces>d__7 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private object <>2__current; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <ServerGetPieces>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; <request>5__2 = UnityWebRequest.Get("http://127.0.0.1:3333/pieces"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; if ((int)<request>5__2.result == 1) { ServerPatches.piecesraw = Encoding.UTF8.GetString(<request>5__2.downloadHandler.data); } else { ZLog.LogError((object)"error in pieces request"); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ServerGetRecipes>d__6 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private object <>2__current; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <ServerGetRecipes>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; <request>5__2 = UnityWebRequest.Get("http://127.0.0.1:3333/recipes"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; if ((int)<request>5__2.result == 1) { ServerPatches.recipesraw = Encoding.UTF8.GetString(<request>5__2.downloadHandler.data); } else { ZLog.LogError((object)"error in recipes request"); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ServerGetSkillcaps>d__8 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private object <>2__current; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <ServerGetSkillcaps>d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; <request>5__2 = UnityWebRequest.Get("http://127.0.0.1:3333/skills"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; if ((int)<request>5__2.result == 1) { DbSkills[] array = SimpleJson.DeserializeObject<DbSkills[]>(ServerPatches.skillsraw = Encoding.UTF8.GetString(<request>5__2.downloadHandler.data)); if (array != null) { ServerPatches.skills.Clear(); DbSkills[] array2 = array; foreach (DbSkills item in array2) { ServerPatches.skills.Add(item); } ZLog.Log((object)$"[VRP] Server now has {ServerPatches.skills.Count} skill groups in memory."); } else { ZLog.LogError((object)"error skills json"); } } else { ZLog.LogError((object)"error in skills request"); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ServerGetWhitelist>d__4 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private object <>2__current; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <ServerGetWhitelist>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; <request>5__2 = UnityWebRequest.Get("http://127.0.0.1:3333/whitelist/"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; return true; case 1: <>1__state = -1; if ((int)<request>5__2.result == 1) { DbWhitelist[] array = SimpleJson.DeserializeObject<DbWhitelist[]>(Encoding.UTF8.GetString(<request>5__2.downloadHandler.data)); if (array != null) { ServerPatches.whitelist.Clear(); DbWhitelist[] array2 = array; foreach (DbWhitelist item in array2) { ServerPatches.whitelist.Add(item); } } else { ZLog.LogError((object)"error whitelist json"); } } else { ZLog.LogError((object)"error in whitelist request"); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WhitelistAuth>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private object <>2__current; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public string steamid; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public string charName; public int cid; public int pid; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public DbWhitelist originalObj; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <WhitelistAuth>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown bool result; try { switch (<>1__state) { default: result = false; break; case 0: { <>1__state = -1; string s = SimpleJson.SerializeObject((object)new DbWhitelistNew { steamid = steamid, charName = charName, cid = cid, pid = pid }); <request>5__2 = new UnityWebRequest("http://127.0.0.1:3333/whitelist/new", "POST"); <>1__state = -3; byte[] bytes = Encoding.UTF8.GetBytes(s); <request>5__2.uploadHandler = (UploadHandler)new UploadHandlerRaw(bytes); <request>5__2.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); <request>5__2.SetRequestHeader("Content-Type", "application/json"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; result = true; break; } case 1: <>1__state = -3; ZLog.Log((object)("api whitelist sent " + charName + " " + steamid)); originalObj.isAuthenticating = false; result = false; <>m__Finally1(); break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<request>5__2 != null) { ((IDisposable)<request>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WhitelistPermadeath>d__3 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private object <>2__current; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public DbWhitelist deadplayer; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] private UnityWebRequest <request>5__2; object IEnumerator<object>.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public <WhitelistPermadeath>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <request>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown bool result; try { switch (<>1__state) { default: result = false; break; case 0: { <>1__state = -1; deadplayer.permadeath = true; string s = SimpleJson.SerializeObject((object)deadplayer); <request>5__2 = new UnityWebRequest("http://127.0.0.1:3333/whitelist/dead", "POST"); <>1__state = -3; byte[] bytes = Encoding.UTF8.GetBytes(s); <request>5__2.uploadHandler = (UploadHandler)new UploadHandlerRaw(bytes); <request>5__2.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); <request>5__2.SetRequestHeader("Content-Type", "application/json"); <>2__current = <request>5__2.SendWebRequest(); <>1__state = 1; result = true; break; } case 1: <>1__state = -3; ZLog.Log((object)("api permadeath sent " + deadplayer.charactername + " " + deadplayer.steamid)); result = false; <>m__Finally1(); break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<request>5__2 != null) { ((IDisposable)<request>5__2).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static IEnumerator LogInsert(DbLog logEntry) { return LogInsert(SimpleJson.SerializeObject((object)logEntry)); } [IteratorStateMachine(typeof(<LogInsert>d__1))] public static IEnumerator LogInsert(string json) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LogInsert>d__1(0) { json = json }; } [IteratorStateMachine(typeof(<WhitelistAuth>d__2))] public static IEnumerator WhitelistAuth(string steamid, string charName, int pid, int cid, DbWhitelist originalObj) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WhitelistAuth>d__2(0) { steamid = steamid, charName = charName, pid = pid, cid = cid, originalObj = originalObj }; } [IteratorStateMachine(typeof(<WhitelistPermadeath>d__3))] public static IEnumerator WhitelistPermadeath(DbWhitelist deadplayer) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WhitelistPermadeath>d__3(0) { deadplayer = deadplayer }; } [IteratorStateMachine(typeof(<ServerGetWhitelist>d__4))] public static IEnumerator ServerGetWhitelist() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ServerGetWhitelist>d__4(0); } [IteratorStateMachine(typeof(<ServerGetGroups>d__5))] public static IEnumerator ServerGetGroups() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ServerGetGroups>d__5(0); } [IteratorStateMachine(typeof(<ServerGetRecipes>d__6))] public static IEnumerator ServerGetRecipes() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ServerGetRecipes>d__6(0); } [IteratorStateMachine(typeof(<ServerGetPieces>d__7))] public static IEnumerator ServerGetPieces() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ServerGetPieces>d__7(0); } [IteratorStateMachine(typeof(<ServerGetSkillcaps>d__8))] public static IEnumerator ServerGetSkillcaps() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ServerGetSkillcaps>d__8(0); } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public class StatusOverlayManager : MonoBehaviour { private static StatusOverlayManager _instance; private GameObject _masterOverlay; private Image _overlayImage; private float _targetAlpha; private const float FadeSpeed = 1.5f; public static StatusOverlayManager Instance { get { //IL_0012: 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) //IL_0027: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("StatusOverlayManager_AutoCreated"); _instance = val.AddComponent<StatusOverlayManager>(); Object.DontDestroyOnLoad((Object)val); } return _instance; } } private void Awake() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { _instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } else if ((Object)(object)_instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } _masterOverlay = VignetteHelper.CreateOverlay("MasterStatusOverlay", new Color(1f, 1f, 1f, 0f)); if ((Object)(object)_masterOverlay != (Object)null) { _overlayImage = _masterOverlay.GetComponentInChildren<Image>(); } } private void Update() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_masterOverlay == (Object)null || (Object)(object)_overlayImage == (Object)null) { return; } float a = ((Graphic)_overlayImage).color.a; if (!Mathf.Approximately(a, _targetAlpha)) { float num = Mathf.MoveTowards(a, _targetAlpha, Time.deltaTime * 1.5f); VignetteHelper.SetIntensity(_masterOverlay, num); if (num <= 0f && _targetAlpha == 0f) { _masterOverlay.SetActive(false); } } } public void UpdateOverlay(Color color, float intensity, bool enabled, float strength = 1f) { //IL_0036: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_masterOverlay == (Object)null) { return; } if (enabled) { _targetAlpha = intensity * strength; _masterOverlay.SetActive(true); if ((Object)(object)_overlayImage != (Object)null) { Color color2 = color; color2.a = ((Graphic)_overlayImage).color.a; ((Graphic)_overlayImage).color = color2; } } else { _targetAlpha = 0f; } } } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] internal static class BundleCache { [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public sealed class Scope : IDisposable { private readonly string _path; public AssetBundle Bundle { get; } public Scope(string keyOrPath) { _path = Resolve(keyOrPath); Bundle = Acquire(_path); } public void Dispose() { Release(_path); } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 1, 1, 0, 1 })] private static readonly Dictionary<string, (AssetBundle bundle, int refs)> _cache = new Dictionary<string, (AssetBundle, int)>(); private static readonly Dictionary<string, string> _aliases = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "bandage", "Arielle-ValheimRoleplay/Assets/bandage" }, { "ploam", "Arielle-ValheimRoleplay/Assets/ploam" }, { "mushbundle", "Arielle-ValheimRoleplay/Assets/gold" }, { "bonefirebundle", "Arielle-ValheimRoleplay/Assets/bonefire" }, { "vrpbundle", "Arielle-ValheimRoleplay/Assets/stoneage" }, { "valonbundle", "Arielle-ValheimRoleplay/Assets/valon" }, { "phatbundle", "Arielle-ValheimRoleplay/Assets/phats" }, { "loraxbundle", "Arielle-ValheimRoleplay/Assets/loraxia" }, { "bronzehelm", "Arielle-ValheimRoleplay/Assets/bronzehelmsrgb" } }; private static string Resolve(string keyOrPath) { if (string.IsNullOrWhiteSpace(keyOrPath)) { throw new ArgumentException("Bundle key/path is null or empty.", "keyOrPath"); } if (keyOrPath.Contains("/") || keyOrPath.Contains("\\")) { return keyOrPath; } if (_aliases.TryGetValue(keyOrPath, out var value)) { return value; } return keyOrPath; } public static AssetBundle GetBundle(string keyOrPath) { return Acquire(keyOrPath); } public static AssetBundle Acquire(string keyOrPath) { string text = Resolve(keyOrPath); if (_cache.TryGetValue(text, out (AssetBundle, int) value)) { _cache[text] = (value.Item1, value.Item2 + 1); return value.Item1; } AssetBundle val = AssetUtils.LoadAssetBundle(text); if ((Object)(object)val != (Object)null) { GameObject[] array = val.LoadAllAssets<GameObject>(); foreach (GameObject val2 in array) { Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true); for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] == (Object)null) { ZLog.LogError((object)("[VRP ERROR] Bundle '" + keyOrPath + "' contains a MISSING SCRIPT on Prefab: '" + ((Object)val2).name + "'")); ZLog.LogError((object)("[VRP FIX] Open Unity, find '" + ((Object)val2).name + "', remove the 'Missing (Script)' component, and re-export.")); } } } } _cache[text] = (val, 1); return val; } public static void Release(string keyOrPath) { string key = Resolve(keyOrPath); if (_cache.TryGetValue(key, out (AssetBundle, int) value)) { int num = value.Item2 - 1; if (num <= 0) { value.Item1.Unload(false); _cache.Remove(key); } else { _cache[key] = (value.Item1, num); } } } } internal static class Env { public static bool IsDedicated { get { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) { return (int)SystemInfo.graphicsDeviceType == 4; } return true; } } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static class ServingTrayHelper { private static void CreatePrefabForServingTray(GameObject prefab, string name, string description, string category = "VRP", string displayName = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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 PieceConfig val = new PieceConfig(); val.Name = displayName ?? name; val.Description = description; val.PieceTable = PieceTables.ServingTray; val.Category = category; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = name, Amount = 1 } }; PieceConfig val2 = val; PieceManager.Instance.AddPiece(new CustomPiece(prefab, false, val2)); } public static void AddToServingTray(CustomItem item, string category = "VRP") { CreatePrefabForServingTray(item.ItemPrefab, ((Object)item.ItemDrop).name, item.ItemDrop.m_itemData.m_shared.m_description, category, item.ItemDrop.GetHoverName()); } public static void AddToServingTray(string foodPrefabName, string category = "VRP") { GameObject prefab = PrefabManager.Instance.GetPrefab(foodPrefabName); ItemDrop val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<ItemDrop>() : null); if (!Object.op_Implicit((Object)(object)val)) { ZLog.LogWarning((object)("Food prefab '" + foodPrefabName + "' not found or missing ItemDrop.")); return; } string text = "ST_" + ((Object)prefab).name; if (PieceManager.Instance.GetPiece(text) != null) { ZLog.Log((object)("Piece '" + text + "' already added; skipping.")); return; } string hoverName = val.GetHoverName(); string description = val.m_itemData?.m_shared?.m_description ?? ""; val.m_itemData?.m_shared?.m_icons?.FirstOrDefault(); CreatePrefabForServingTray(prefab, foodPrefabName, description, category, hoverName); } } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [BepInPlugin("Arielle.ValheimRoleplay", "ValheimRoleplay", "2.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class VRPMod : BaseUnityPlugin { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(0)] public enum Toggle { On = 1, Off = 0 } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(0)] private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(2)] public string Category; [UsedImplicitly] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 2, 1 })] public Action<ConfigEntryBase> CustomDrawer; } internal const string ModName = "ValheimRoleplay"; internal const string ModVersion = "2.1.2"; internal const string Author = "Arielle"; private const string ModGUID = "Arielle.ValheimRoleplay"; private static string ConfigFileName = "Arielle.ValheimRoleplay.cfg"; private static string ConfigFileFullPath; public static VRPMod Instance; public static ConfigEntry<string> _vrpLore; public static ConfigEntry<float> _drunkChance; public static ConfigEntry<Biome> gatedBiomes; public static ConfigEntry<bool> preventBuilding; public static ConfigEntry<bool> preventExploring; public static ConfigEntry<bool> preventInteraction; public static ConfigEntry<bool> _lockTimeEnabled; public static ConfigEntry<float> _lockedTimeValue; public static ConfigEntry<bool> _eternalWinterEnabled; public static ConfigEntry<int> _coinCostLevel2; public static ConfigEntry<int> _coinCostLevel3; public static ConfigEntry<int> _coinCostLevel4; internal static string ConnectionError; private readonly Harmony _harmony = new Harmony("Arielle.ValheimRoleplay"); public static readonly ManualLogSource ValheimRoleplayLogger; private static readonly ConfigSync ConfigSync; private static ConfigEntry<Toggle> _serverConfigLocked; internal static ConfigEntry<Toggle> _debugMode; public static bool DebugMode() { return _debugMode.Value == Toggle.On; } public void Awake() { //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown Instance = this; _serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only."); ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked); _vrpLore = config("2 - VRP", "Season Lore", "Hello World", "Intro text for new players."); ConfigSync.AddConfigEntry<string>(_vrpLore); _debugMode = config("2 - VRP", "Debug Mode", Toggle.Off, "If on, will write extra logs. May cause performance issues."); ConfigSync.AddConfigEntry<Toggle>(_debugMode); _drunkChance = config("3 - Custom", "Drunk Chance", 0.25f, "Chance [0..1] to gain Drunk when consuming an alcoholic drink."); ConfigSync.AddConfigEntry<float>(_drunkChance); gatedBiomes = config<Biome>("4 - Progression", "Gated Biomes", (Biome)0, "Biome list."); ConfigSync.AddConfigEntry<Biome>(gatedBiomes); preventBuilding = config("4 - Progression", "No Build", value: true, "Prevent usage of hammers, hoe, cultivator."); ConfigSync.AddConfigEntry<Biome>(gatedBiomes); preventExploring = config("4 - Progression", "No Explore", value: true, "Prevent minimap from exploring."); ConfigSync.AddConfigEntry<Biome>(gatedBiomes); preventInteraction = config("4 - Progression", "No Interaction", value: true, "Prevent interaction with any interactable object."); ConfigSync.AddConfigEntry<Biome>(gatedBiomes); _eternalWinterEnabled = config("5 - Winter", "Enabled", value: true, "Begin the eternal winter."); ConfigSync.AddConfigEntry<bool>(_eternalWinterEnabled); _lockTimeEnabled = config("6 - Freeze Time", "Enabled", value: true, "Enable the time lock."); ConfigSync.AddConfigEntry<bool>(_eternalWinterEnabled); _lockedTimeValue = config("6 - Time of Day", "Time of Day", 0.6f, "Freeze time."); ConfigSync.AddConfigEntry<float>(_lockedTimeValue); _coinCostLevel2 = config("7 - Coin Costs", "Level 2 Cost", 10, "Coin cost for Quality level 2 gear."); _coinCostLevel3 = config("7 - Coin Costs", "Level 3 Cost", 50, "Coin cost for Quality level 3 gear."); _coinCostLevel4 = config("7 - Coin Costs", "Level 4 Cost", 500, "Coin cost for Quality level 4 gear."); Application.logMessageReceived += new LogCallback(SuppressMissingScriptLogs); _harmony.PatchAll(); JotunnPatches.AddVariants(); SetupWatcher(); } private void SuppressMissingScriptLogs(string condition, string stackTrace, LogType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)type == 2) { condition.Contains("The referenced script on this Behaviour"); } } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { ValheimRoleplayLogger.LogDebug((object)"ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { ValheimRoleplayLogger.LogError((object)("There was an issue loading your " + ConfigFileName)); ValheimRoleplayLogger.LogError((object)"Please check your config entries for spelling and format!"); } } private ConfigEntry<T> config<[<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val); ConfigSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedSetting; return val2; } private ConfigEntry<T> config<[<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } static VRPMod() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; ConnectionError = ""; ValheimRoleplayLogger = Logger.CreateLogSource("ValheimRoleplay"); ConfigSync = new ConfigSync("Arielle.ValheimRoleplay") { DisplayName = "ValheimRoleplay", CurrentVersion = "2.1.2", MinimumRequiredVersion = "2.1.2" }; _serverConfigLocked = null; _debugMode = null; } } public static class KeyboardExtensions { public static bool IsKeyDown(this KeyboardShortcut shortcut) { //IL_0002: 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) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey)) { return ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey); } return false; } public static bool IsKeyHeld(this KeyboardShortcut shortcut) { //IL_0002: 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) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey)) { return ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey); } return false; } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] public static class RegisterAndCheckVersion { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown VRPMod.ValheimRoleplayLogger.LogDebug((object)"Registering version RPC handler"); peer.m_rpc.Register<ZPackage>("ValheimRoleplay_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_ValheimRoleplay_Version); VRPMod.ValheimRoleplayLogger.LogInfo((object)"Invoking version check"); ZPackage val = new ZPackage(); val.Write("2.1.2"); peer.m_rpc.Invoke("ValheimRoleplay_VersionCheck", new object[1] { val }); } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static class VerifyClient { private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance) { if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc)) { return true; } VRPMod.ValheimRoleplayLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting")); rpc.Invoke("Error", new object[1] { 3 }); return false; } private static void Postfix(ZNet __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "ValheimRoleplayRequestAdminSync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] public class ShowConnectionError { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] private static void Postfix(FejdStartup __instance) { if (__instance.m_connectionFailedPanel.activeSelf) { __instance.m_connectionFailedError.fontSizeMax = 25f; __instance.m_connectionFailedError.fontSizeMin = 15f; TMP_Text connectionFailedError = __instance.m_connectionFailedError; connectionFailedError.text = connectionFailedError.text + "\n" + VRPMod.ConnectionError; } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] public static class RemoveDisconnectedPeerFromVerified { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] private static void Prefix(ZNetPeer peer, ref ZNet __instance) { if (__instance.IsServer()) { VRPMod.ValheimRoleplayLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list")); RpcHandlers.ValidatedPeers.Remove(peer.m_rpc); } } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static class RpcHandlers { public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>(); public static void RPC_ValheimRoleplay_Version(ZRpc rpc, ZPackage pkg) { string text = pkg.ReadString(); VRPMod.ValheimRoleplayLogger.LogInfo((object)("Version check, local: 2.1.2, remote: " + text)); if (text != "2.1.2") { VRPMod.ConnectionError = "ValheimRoleplay Installed: 2.1.2\n Needed: " + text; if (ZNet.instance.IsServer()) { VRPMod.ValheimRoleplayLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting...")); rpc.Invoke("Error", new object[1] { 3 }); } } else if (!ZNet.instance.IsServer()) { VRPMod.ValheimRoleplayLogger.LogInfo((object)"Received same version from server!"); } else { VRPMod.ValheimRoleplayLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list")); ValidatedPeers.Add(rpc); } } public static string ComputeHashForMod() { using SHA256 sHA = SHA256.Create(); byte[] array = sHA.ComputeHash(File.ReadAllBytes(Assembly.GetExecutingAssembly().Location)); StringBuilder stringBuilder = new StringBuilder(); byte[] array2 = array; foreach (byte b in array2) { stringBuilder.Append(b.ToString("X2")); } return stringBuilder.ToString(); } } } namespace ValheimRoleplay.Helpers { [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static class PlantableHelper { [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public class PlantablePickableConfig { public string PlantName; private string _pickableName; private string _prefabName; private string _displayName; private string _description; public RequirementConfig[] Requirements; public int Yield = 3; public float GrowTime = 3000f; public float MinScale = 1f; public float MaxScale = 1.5f; public bool NeedCultivatedGround = true; public Biome AllowedBiomes = (Biome)895; public string PickableName { get { if (string.IsNullOrEmpty(_pickableName)) { return "Pickable_" + PlantName; } return _pickableName; } set { _pickableName = value; } } public string PrefabName { get { if (string.IsNullOrEmpty(_prefabName)) { return "sapling_" + PlantName; } return _prefabName; } set { _prefabName = value; } } public string DisplayName { get { if (string.IsNullOrEmpty(_displayName)) { return PlantName; } return _displayName; } set { _displayName = value; } } public string Description { get { if (string.IsNullOrEmpty(_description)) { return "Plant " + DisplayName; } return _description; } set { _description = value; } } } public static CustomPiece MakePlantablePickable(PlantablePickableConfig cfg) { //IL_000b: 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_001b: 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_0033: 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_0069: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00c6: 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_00f0: Unknown result type (might be due to invalid IL or missing references) try { CustomPiece val = new CustomPiece(cfg.PrefabName, "sapling_carrot", new PieceConfig { PieceTable = "_CultivatorPieceTable", Name = cfg.PlantName, Description = cfg.Description, Icon = PrefabManager.Instance.GetPrefab(cfg.PlantName).GetComponent<ItemDrop>().m_itemData.GetIcon(), Requirements = cfg.Requirements }); Transform val2 = val.PiecePrefab.transform.Find("Visual"); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } GameObject val3 = Object.Instantiate<GameObject>(PrefabManager.Instance.GetPrefab(cfg.PickableName), val.PiecePrefab.transform); ((Object)val3).name = "Visual"; val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = Vector3.one * 0.6f; Component[] components = val3.GetComponents<Component>(); foreach (Component val4 in components) { if (!(val4 is Transform) && !(val4 is MeshFilter) && !(val4 is MeshRenderer)) { Object.DestroyImmediate((Object)(object)val4); } } val3.layer = LayerMask.NameToLayer("piece"); string text = "cultivated_" + cfg.PlantName; GameObject val5 = PrefabManager.Instance.CreateClonedPrefab(text, cfg.PickableName); if ((Object)(object)val5 != (Object)null) { Pickable component = val5.GetComponent<Pickable>(); if ((Object)(object)component != (Object)null) { component.m_amount = cfg.Yield; component.m_respawnTimeMinutes = 0f; component.m_hideWhenPicked = null; } PrefabManager.Instance.AddPrefab(val5); } Plant component2 = val.PiecePrefab.GetComponent<Plant>(); if ((Object)(object)component2 != (Object)null) { component2.m_name = cfg.PlantName; component2.m_minScale = cfg.MinScale; component2.m_maxScale = cfg.MaxScale; component2.m_needCultivatedGround = cfg.NeedCultivatedGround; component2.m_growTime = cfg.GrowTime; component2.m_grownPrefabs = null; component2.m_grownPrefabs = (GameObject[])(object)new GameObject[1] { val5 }; } PieceManager.Instance.AddPiece(val); } catch (Exception arg) { ZLog.LogError((object)$"[VRP] Error creating plantable '{cfg?.PlantName}': {arg}"); throw; } return null; } } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public static class RecipeHelper { public static void AddCoinExchange(string name, int coinAmount, params string[] trophies) { //IL_002b: 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_0037: 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_0049: 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_005c: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown RequirementConfig[] requirements = ((IEnumerable<string>)trophies).Select((Func<string, RequirementConfig>)([<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(0)] (string t) => new RequirementConfig { Item = t, Amount = 1 })).ToArray(); CustomRecipe val = new CustomRecipe(new RecipeConfig { Name = name, Item = "Coins", Amount = coinAmount, Requirements = requirements, RequireOnlyOneIngredient = true }); ItemManager.Instance.AddRecipe(val); } public static void addMaterial(AssetBundle bundle, string prefabname) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown try { GameObject val = bundle.LoadAsset<GameObject>(prefabname); if (Object.op_Implicit((Object)(object)val)) { CustomItem val2 = new CustomItem(val, true); ItemManager.Instance.AddItem(val2); if (VRPMod.DebugMode()) { ZLog.Log((object)("vrp added material " + prefabname)); } } else { ZLog.LogWarning((object)("vrp did not find prefab " + prefabname)); } } catch (Exception ex) { Logger.LogError((object)("vrp failed to add item " + prefabname)); Logger.LogError((object)ex); } } public static void addvrpitem(string prefabname, ref AssetBundle ab, ItemConfig ic) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown try { GameObject val = ab.LoadAsset<GameObject>(prefabname); if (Object.op_Implicit((Object)(object)val)) { CustomItem val2 = new CustomItem(val, true, ic); ItemManager.Instance.AddItem(val2); if (VRPMod.DebugMode()) { ZLog.Log((object)("vrp added item " + prefabname)); } } else { ZLog.LogWarning((object)("vrp did not find prefab " + prefabname)); } } catch (Exception ex) { Logger.LogError((object)(prefabname + ex.Message)); } } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static class VignetteHelper { private static Sprite _generatedVignette; public static GameObject CreateOverlay(string name, Color color, bool startEnabled = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: 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_004c: 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_009f: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); Object.DontDestroyOnLoad((Object)(object)val); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 90; CanvasScaler obj2 = val.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); GameObject val2 = new GameObject("VignetteImage"); val2.transform.SetParent(val.transform); Image obj3 = val2.AddComponent<Image>(); if ((Object)(object)_generatedVignette == (Object)null) { _generatedVignette = CreateRadialSprite(); } obj3.sprite = _generatedVignette; obj3.type = (Type)0; ((Graphic)obj3).color = color; ((Graphic)obj3).raycastTarget = false; RectTransform component = ((Component)obj3).GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.one; val.SetActive(startEnabled); return val; } private static Sprite CreateRadialSprite() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0097: 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_002c: 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_0065: Unknown result type (might be due to invalid IL or missing references) int num = 256; Texture2D val = new Texture2D(num, num); ((Texture)val).wrapMode = (TextureWrapMode)1; float num2 = (float)num / 2f; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = Mathf.Clamp01(Mathf.Pow(Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) / num2, 2.5f)); val.SetPixel(j, i, new Color(1f, 1f, 1f, num3)); } } val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f)); } public static void SetIntensity(GameObject overlay, float intensity) { //IL_001b: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)overlay == (Object)null)) { Image componentInChildren = overlay.GetComponentInChildren<Image>(); if ((Object)(object)componentInChildren != (Object)null) { Color color = ((Graphic)componentInChildren).color; color.a = Mathf.Clamp(intensity, 0f, 0.95f); ((Graphic)componentInChildren).color = color; } } } } } namespace ValheimRoleplay.Patches { [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public static class MessageData { private static readonly Random _rng = new Random(); private static readonly string[] FarmerWardNoAccessMessages = new string[10] { "Hands off, thief. The soil remembers.", "You feel eyes on your back. Put it down.", "Not yours. Walk away while you still can.", "The ward hums… as if it knows your name.", "Touch it again and the farmers will hear of it.", "Nox whispers in your ear... \ud835\udd31\ud835\udd1e\ud835\udd28\ud835\udd22 \ud835\udd26\ud835\udd31 \ud835\udd1e\ud835\udd2b\ud835\udd21 ℑ \ud835\udd30\ud835\udd25\ud835\udd1e\ud835\udd29\ud835\udd29 \ud835\udd31\ud835\udd1e\ud835\udd28\ud835\udd22 \ud835\udd36\ud835\udd2c\ud835\udd32.", "\ud835\udd17\ud835\udd25\ud835\udd22 \ud835\udd0f\ud835\udd26\ud835\udd24\ud835\udd25\ud835\udd31 \ud835\udd30\ud835\udd22\ud835\udd22\ud835\udd30 \ud835\udd31\ud835\udd25\ud835\udd22 \ud835\udd25\ud835\udd1e\ud835\udd2b\ud835\udd21 \ud835\udd31\ud835\udd25\ud835\udd1e\ud835\udd31 \ud835\udd20\ud835\udd2c\ud835\udd33\ud835\udd22\ud835\udd31\ud835\udd30. \ud835\udd07\ud835\udd2f\ud835\udd1e\ud835\udd34 \ud835\udd1f\ud835\udd1e\ud835\udd20\ud835\udd28, \ud835\udd2c\ud835\udd2f \ud835\udd1f\ud835\udd22 \ud835\udd2f\ud835\udd22\ud835\udd21\ud835\udd32\ud835\udd20\ud835\udd22\ud835\udd21 \ud835\udd31\ud835\udd2c \ud835\udd1e\ud835\udd30\ud835\udd25.", "\ud835\udd17\ud835\udd25\ud835\udd22 \ud835\udd16\ud835\udd2c\ud835\udd29\ud835\udd30\ud835\udd34\ud835\udd2c\ud835\udd2f\ud835\udd2b \ud835\udd30\ud835\udd2c\ud835\udd34 \ud835\udd34\ud835\udd26\ud835\udd31\ud835\udd25 \ud835\udd30\ud835\udd34\ud835\udd22\ud835\udd1e\ud835\udd31; \ud835\udd31\ud835\udd25\ud835\udd22 \ud835\udd31\ud835\udd25\ud835\udd26\ud835\udd22\ud835\udd23 \ud835\udd2f\ud835\udd22\ud835\udd1e\ud835\udd2d\ud835\udd30 \ud835\udd2c\ud835\udd2b\ud835\udd29\ud835\udd36 \ud835\udd30\ud835\udd2c\ud835\udd2f\ud835\udd2f\ud835\udd2c\ud835\udd34.", "\ud835\udd04 \ud835\udd25\ud835\udd2c\ud835\udd29\ud835\udd29\ud835\udd2c\ud835\udd34 \ud835\udd25\ud835\udd1e\ud835\udd2f\ud835\udd33\ud835\udd22\ud835\udd30\ud835\udd31 \ud835\udd23\ud835\udd2c\ud835\udd2f \ud835\udd1e \ud835\udd25\ud835\udd2c\ud835\udd29\ud835\udd29\ud835\udd2c\ud835\udd34 \ud835\udd30\ud835\udd2c\ud835\udd32\ud835\udd29. \ud835\udd17\ud835\udd25\ud835\udd22 \ud835\udd10\ud835\udd26\ud835\udd30\ud835\udd31 \ud835\udd30\ud835\udd25\ud835\udd1e\ud835\udd29\ud835\udd29 \ud835\udd1f\ud835\udd22 \ud835\udd36\ud835\udd2c\ud835\udd32\ud835\udd2f \ud835\udd2c\ud835\udd2b\ud835\udd29\ud835\udd36 \ud835\udd2a\ud835\udd22\ud835\udd1e\ud835\udd29.", "You swear the crops just *watched* you." }; public static string GetFarmerWardMessage() { if (FarmerWardNoAccessMessages.Length == 0) { return "No access."; } lock (_rng) { return FarmerWardNoAccessMessages[_rng.Next(FarmerWardNoAccessMessages.Length)]; } } } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public static class ModData { public static readonly List<string> RequiredMods = new List<string> { "COM.JOTUNN.JOTUNN", "ARIELLE.VALHEIMROLEPLAY", "ARIELLE.RPCHATTER", "ARIELLE.BESTDRESSED", "SOLOREDIS.RTDBIOMES", "1010101110.VRPSTABLE", "ASHARPPEN.VALHEIM.SPAWN_THAT", "ASHARPPEN.VALHEIM.DROP_THAT", "ORG.BEPINEX.PLUGINS.SERVERCHARACTERS", "AZUMATT.AZUANTIARTHRITICCRAFTING", "ORG.JROBSONCHASE.VALHEIM.PLUGINS.POSITIONALAUDIO", "COM.VALHEIMMODDING.NEWTONSOFTJSONDETECTOR", "AZUMATT.FASTLINK", "ORG.BEPINEX.PLUGINS.CREATURELEVELCONTROL", "BLACKS7AR.COREWOODPIECES", "BLACKS7AR.OREMINES", "BLACKS7AR.FINEWOODPIECES", "ORG.BEPINEX.PLUGINS.BACKPACKS", "BLACKS7AR.MAGICREVAMP", "CEBERO.TORVALDSAFFORDABLEPAINTERS", "COM.DRAKEMODS.DRAKESRENAMEIT", "COOKIEMILK.README", "GRAVEBEAR.ODINSFOODBARRELS", "BETTERCONTINENTS", "HU.JARD.CLEARSKIES", "SHUDNAL.CIRCLETEXTENDED", "SHUDNAL.MOREGATESEXTENDED", "SOUTHSIL.SOUTHSILARMOR", "ITEM_STAND_ALL_ITEMS", "EXPAND_WORLD_DATA", "ORG.BEPINEX.PLUGINS.GAPFILLER", "COM.BENTO.MISSINGPIECES", "ORG.BEPINEX.PLUGINS.MOREMISSINGPIECES" }; public static readonly List<string> OptionalMods = new List<string> { "BLACKS7AR.ONEHANDWEAPONONTHEHIP", "BLACKS7AR.WEAPONHOLSTEROVERHAUL", "ZENDRAGON.ZEN.MODLIB", "ZENDRAGON.ZENREDECORATE", "COM.VALHEIMMODDING.YAMLDOTNETDETECTOR", "BRUCE.VALHEIM.COMFYMODS.GIZMO", "AZUMATT.SEARCHABLEBUILDMENU", "NEOBOTICS.VALHEIM_MOD.HUDCOMPASS", "BRUCE.VALHEIM.COMFY.DUMPSTERFIRE", "AZUMATT.AZUHOVERSTATS", "ADVIZE.PLANTEASILY", "ARIELLE.MOREMAPPINS", "COM.MAXSCH.VALHEIM.WHICHMODADDEDTHIS", "COM.MAXSCH.VALHEIM.LOCALIZATIONCACHE", "ORG.BEPINEX.VALHEIM.DISPLAYINFO", "COM.ORIANAVENTURE.MOD.NOGRASS", "ZENDRAGON.ZENITEMSTANDS", "COM.MAXSCH.VALHEIM.TIMEOUTLIMIT", "CW_JESSE.BETTERNETWORKING", "REDSEIKO.VALHEIM.SEARSCATALOG", "AZUMATT.FIRSTPERSONMODE", "VALHEIMADJUSTEXPOSURE", "VALHEIMADJUSTBRIGHTNESS" }; public static readonly List<string> AdminMods = new List<string> { "UPGRADE_WORLD", "SERVER_DEVCOMMANDS", "SKTOOLBOX", "COOLEY.EASYSPAWNER", "TERRAINRESET", "MAPTELEPORT", "MARCOPOGO.PLANBUILD", "UNITYEXPLORER", "INFINITY_HAMMER", "VNEI", "DEVCOMMANDS", "XRAY", "ESP", "WORLD_EDIT_COMMANDS", "ZONESCOUTER" }; } [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public static class PlantData { public static readonly Dictionary<string, string> PlantAnywhere = new Dictionary<string, string> { { "Beech_Sapling", "Beech sapling" }, { "Birch_Sapling", "Birch Sapling" }, { "FirTree_Sapling", "Fir Sapling" }, { "Oak_Sapling", "Oak Sapling" }, { "PineTree_Sapling", "Pine Sapling" }, { "sapling_barley", "Barley" }, { "sapling_jotunpuffs", "Jotunpuffs" }, { "sapling_magecap", "Magecap" } }; public static readonly List<PlantableHelper.PlantablePickableConfig> PickablePlantConfigs = new List<PlantableHelper.PlantablePickableConfig> { new PlantableHelper.PlantablePickableConfig { PlantName = "Mushroom", PickableName = "Pickable_Mushroom", PrefabName = "sapling_mushroom_r", DisplayName = "Mushroom", Description = "Grow mushrooms with this quick trick!", Yield = 6, Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "Mushroom", Amount = 2 }, new RequirementConfig { Item = "BoneFragments", Amount = 1 } } }, new PlantableHelper.PlantablePickableConfig { PlantName = "MushroomYellow", PickableName = "Pickable_Mushroom_yellow", PrefabName = "sapling_mushroom_y", DisplayName = "Yellow Mushroom", Description = "Grow yellow mushrooms", Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "Mushroom", Amount = 2 }, new RequirementConfig { Item = "BoneFragments", Amount = 1 } } }, new PlantableHelper.PlantablePickableConfig { PlantName = "MushroomBlue", PickableName = "Pickable_Mushroom_blue", PrefabName = "sapling_mushroom_blue", DisplayName = "Blue Mushroom", Description = "Grow blue mushrooms", Yield = 6, Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "MushroomBlue", Amount = 2 }, new RequirementConfig { Item = "BoneFragments", Amount = 1 } } }, new PlantableHelper.PlantablePickableConfig { PlantName = "Thistle", PickableName = "Pickable_Thistle", PrefabName = "sapling_thistle", DisplayName = "Thistle", Description = "Grow thistle with this quick trick!", Yield = 6, Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "Thistle", Amount = 2 }, new RequirementConfig { Item = "BoneFragments", Amount = 1 } } }, new PlantableHelper.PlantablePickableConfig { PlantName = "StoneRock", PickableName = "Pickable_StoneRock", PrefabName = "sapling_stonerock", DisplayName = "Rock", Description = "Everyone enjoys a happy rock garden!", Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = 20 } }, Yield = 1 }, new PlantableHelper.PlantablePickableConfig { PlantName = "Dandelion", PickableName = "Pickable_Dandelion", PrefabName = "sapling_dandelion", DisplayName = "Dandelion", Description = "Grow dandelion", Yield = 6, Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "Dandelion", Amount = 2 }, new RequirementConfig { Item = "BoneFragments", Amount = 1 } } }, new PlantableHelper.PlantablePickableConfig { PlantName = "Fiddleheadfern", PickableName = "Pickable_Fiddlehead", PrefabName = "sapling_fiddlehead", DisplayName = "Fiddlehead", Description = "Grow fiddlehead with this quick trick!", Yield = 6, Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "Fiddleheadfern", Amount = 2 }, new RequirementConfig { Item = "BoneFragments", Amount = 1 } } } }; } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] [<4713ac70-5c40-4c8e-abac-415a3e416205>NullableContext(1)] public static class RecipeData { [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public class SimpleRecipe { public string Item { get; set; } public int Amount { get; set; } public string CraftingStation { get; set; } = string.Empty; public Dictionary<string, int> Requirements { get; set; } } [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(0)] public class ComplexRecipe { public string Item { get; set; } public int Amount { get; set; } = 1; public string CraftingStation { get; set; } = string.Empty; public string Description { get; set; } public int StationLevel { get; set; } = 1; [<a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 1, 1, 0 })] [field: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 1, 1, 0 })] public Dictionary<string, (int baseAmount, int perLevel)> Requirements { [return: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 1, 1, 0 })] get; [param: <a8917c20-7ff1-455f-9f19-9daec886b40f>Nullable(new byte[] { 1, 1, 0 })] set; } public string BundleKey { get; set; } } public static readonly Dictionary<int, string> TrophyConversion = new Dictionary<int, string> { { 2, "TrophyBoar,TrophyNeck" }, { 5, "TrophyDeer,TrophyGreydwarf,TrophySkeleton" }, { 10, "TrophyHare,TrophyDvergr,TrophyBjorn,TrophyEikthyr,TrophyForestTroll,TrophyFrostTroll,TrophyGreydwarfBrute,TrophyGreydwarfShaman,TrophySkeletonPoison,TrophyBlob,TrophyDraugr,TrophySurtling,TrophyLeech,TrophyWolf" }, { 20, "TrophyTheElder,TrophySkeletonHildir,TrophyAbomination,TrophyWraith,TrophyDraugrElite,TrophySerpent,TrophyHatchling,TrophyUlv,TrophyFenring,TrophyLox" }, { 30, "TrophyBonemass,TrophyCultist,TrophyGoblin" }, { 40, "TrophyCultist_Hildir,TrophySGolem,TrophyDragonQueen,TrophyBjornUndead,TrophyGrowth,TrophyGoblinShaman,TrophyDeathsquito,TrophyGoblinBrute,TrophySeeker,TrophyAsksvin" }, { 50, "TrophyGoblinBruteBrosBrute,TrophyGoblinBruteBrosShaman,TrophyGoblinKing,TrophyTick,TrophySeekerBrute,TrophyGjall,TrophyCharredArcher,TrophyCharredMage,TrophyCharredMelee" }, { 60, "TrophySeekerQueen,TrophyMorgen,TrophyFallenValkyrie,TrophyFader" } }; public static readonly Dictionary<string, SimpleRecipe> MerchantRecipes = new Dictionary<string, SimpleRecipe> { ["vrp_merchantb0"] = new SimpleRecipe { Item = "Coins", Amount = 10, Requirements = new Dictionary<string, int> { ["AmberPearl"] = 1 } }, ["vrp_merchantb1"] = new SimpleRecipe { Item = "Coins", Amount = 20, Requirements = new Dictionary<string, int> { ["Ruby"] = 1 } }, ["vrp_merchantb3"] = new SimpleRecipe { Item = "Coins", Amount = 5, Requirements = new Dictionary<string, int> { ["Amber"] = 1 } }, ["vrp_merchantb4"] = new SimpleRecipe { Item = "Coins", Amount = 30, Requirements = new Dictionary<string, int> { ["SilverNecklace"] = 1 } }, ["vrp_merchantbb0"] = new SimpleRecipe { Item = "AmberPearl", Amount = 1, Requirements = new Dictionary<string, int> { ["Coins"] = 15 } }, ["vrp_merchantbb1"] = new SimpleRecipe { Item = "Ruby", Amount = 1, Requirements = new Dictionary<string, int> { ["Coins"] = 25 } }, ["vrp_merchantbb3"] = new SimpleRecipe { Item = "Amber", Amount = 1, Requirements = new Dictionary<string, int> { ["Coins"] = 10 } }, ["vrp_merchantbb4"] = new SimpleRecipe { Item = "SilverNecklace", Amount = 1, Requirements = new Dictionary<string, int> { ["Coins"] = 35 } }, ["vrp_merchant9"] = new SimpleRecipe { Item = "FishingBait", Amount = 20, Requirements = new Dictionary<string, int> { ["Floam"] = 10 } }, ["vrp_merchant10"] = new SimpleRecipe { Item = "FishingRod", Amount = 1, Requirements = new Dictionary<string, int> { ["Floam"] = 50, ["Wood"] = 10 } }, ["vrp_merchant11"] = new SimpleRecipe { Item = "HelmetYule", Amount = 1, Requirements = new Dictionary<string, int> { ["DeerHide"] = 1, ["Raspberry"] = 5 } }, ["vrp_merchant12"] = new SimpleRecipe { Item = "BeltStrength", Amount = 1, Requirements = new Dictionary<string, int> { ["TrinketBronzeHealth"] = 1, ["AmberPearl"] = 50, ["BjornHide"] = 10 } }, ["vrp_merchant13"] = new SimpleRecipe { Item = "HelmetDverger", Amount = 1, Requirements = new Dictionary<string, int> { ["Coins"] = 950 } }, ["vrp_merchant14"] = new SimpleRecipe { Item = "Thunderstone", Amount = 1, Requirements = new Dictionary<string, int> { ["Stone"] = 20, ["CryptKey"] = 10 } }, ["vrp_merchant15"] = new SimpleRecipe { Item = "YmirRemains", Amount = 1, Requirements = new Dictionary<string, int> { ["Entrails"] = 30, ["Floam"] = 30, ["TrophyDraugr"] = 1 } }, ["vrp_merchant17"] = new SimpleRecipe { Item = "Floam", Amount = 10, Requirements = new Dictionary<string, int> { ["Coins"] = 20 } }, ["vrp_merchant170"] = new SimpleRecipe { Item = "Gloam", Amount = 1, Requirements = new Dictionary<string, int> { ["Coins"] = 100, ["Floam"] = 5 } }, ["vrp_merchant171"] = new SimpleRecipe { Item = "Guck", Amount = 1, Requirements = new Dictionary<string, int> { ["Pukeberries"] = 10, ["GreydwarfEye"] = 10, ["Coins"] = 20 } }, ["vrp_merchant18"] = new SimpleRecipe { Item = "Crystal", Amount = 1, Requirements = new Dictionary<string, int> { ["Stone"] = 10, ["Coins"] = 25 } }, ["vrp_merchant19"] = new SimpleRecipe { Item = "Tar", Amount = 1, Requirements = new Dictionary<string, int> { ["Resin"] = 25, ["Coal"] = 20, ["Coins"] = 20 } } }; public static readonly Dictionary<string, SimpleRecipe> MagicItems = new Dictionary<string, SimpleRecipe> { ["vrp_fireessence"] = new SimpleRecipe { Item = "BMR_FireEssence", Amount = 5, Requirements = new Dictionary<string, int> { ["Coins"] = 1, ["Floam"] = 1 } }, ["vrp_iceessence"] = new SimpleRecipe { Item = "BMR_IceEssence", Amount = 5, Requirements = new Dictionary<string, int> { ["Coins"] = 1, ["Floam"] = 1 } }, ["vrp_lightningessence"] = new SimpleRecipe { Item = "BMR_LightningEssence", Amount = 5, Requirements = new Dictionary<string, int> { ["Coins"] = 1, ["Floam"] = 1 } }, ["vrp_toxicessence"] = new SimpleRecipe { Item = "BMR_PoisonEssence", Amount = 5, Requirements = new Dictionary<string, int> { ["Coins"] = 1, ["Floam"] = 1 } } }; public static readonly Dictionary<string, SimpleRecipe> MakeItCraftableRecipes; public static readonly Dictionary<string, ComplexRecipe> VRP_Armor; public static readonly Dictionary<string, ComplexRecipe> VRP_Misc; static RecipeData() { Dictionary<string, SimpleRecipe> dictionary = new Dictionary<string, SimpleRecipe>(); dictionary["vrp_barbkit"] = new SimpleRecipe { Item = "BarberKit", Amount = 1, CraftingStation = "piece_workbench", Requirements = new Dictionary<string, int> { ["Tin"] = 5, ["Amber"] = 10, ["DeerHide"] = 5, ["Feathers"] = 50 } }; dictionary["vrp_ironpit"] = new SimpleRecipe { Item = "Ironpit", Amount = 1, CraftingStation = "forge", Requirements = new Dictionary<string, int> { ["Iron"] = 10 } }; dictionary["vrp_firework"] = new SimpleRecipe { Item = "FireworksRocket_White", Amount = 1, CraftingStation = "piece_workbench", Requirements = new Dictionary<string, int> { ["Coins"] = 25 } }; dictionary["vrp_sparkler"] = new SimpleRecipe { Item = "Sparkler", Amount = 1, CraftingStation = "piece_workbench", Requirements = new Dictionary<string, int> { ["Coins"] = 25 } }; dictionary["vrp_hat5"] = new SimpleRecipe { Item = "HelmetHat5", Amount = 1, CraftingStation = "piece_workbench", Requirements = new Dictionary<string,