Decompiled source of MountUpRestored v3.3.13
MountUpRestored.dll
Decompiled 2 weeks 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.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using AllTameable; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using MountUp; using MountUp.ModCompat; using RRRCore; using UnityEngine; using UnityEngine.UI; 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.Callbacks; 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: AssemblyCompany("Microsoft")] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("MountUp")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCopyright("Copyright © Microsoft 2021")] [assembly: AssemblyProduct("MountUp")] [assembly: ComVisible(false)] [assembly: Guid("9e1c6dc2-1a11-4768-96f1-0f71c70e1dbe")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyTrademark("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [BepInPlugin("meldurson.MountUpRestored", "Mount Up Restored", "3.3.13")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Setup : BaseUnityPlugin { public const string PluginGUID = "meldurson.MountUpRestored"; public const string PluginName = "Mount Up Restored"; public const string PluginVersion = "3.3.13"; public static ManualLogSource logger; public static GameObject boarSaddlePrefab; public static ItemDrop boarSaddleItem; public static ItemDrop wolfSaddleItem; public static ItemDrop loxSaddleItem; public static GameObject wolfSaddlePrefab; public static GameObject genericSaddlePrefab; public static GameObject[] tieredSaddlePrefabs = (GameObject[])(object)new GameObject[9]; public static ItemDrop[] tieredSaddleItems = (ItemDrop[])(object)new ItemDrop[9]; public static bool lateLoad = false; public static Vector3 boarMountPos = new Vector3(-0.509f, -0.2195f, 0.0495f); public static Vector3 wolfMountPos = new Vector3(-0.393f, -0.127f, 0.023f); public static Vector3 boarSaddlePos = new Vector3(0.0189f, -0.283f, 0f); public static Vector3 wolfSaddlePos = new Vector3(0.00398f, -0.177f, 0f); public static Vector3 boarLocalScale = new Vector3(0.9f, 1f, 1f); public static Vector3 wolfLocalScale = new Vector3(0.9f, 1.27f, 1.05f); public static Vector3 rotationAdjust = new Vector3(0f, -90f, 180f); public static Vector3 posDefault = new Vector3(0f, 0.01f, 0f); public static ConfigEntry<bool> canMountPlayer; public static ConfigEntry<float> BoarStamina; public static ConfigEntry<float> WolfStamina; public static ConfigEntry<float> LoxStamina; public static ConfigEntry<float> AsksvinStamina; public static ConfigEntry<float> FedStaminaMultiplier; public static ConfigEntry<bool> adjustCustom; public static ConfigEntry<KeyboardShortcut> adjustCustomModeSwitch; public static KeyboardShortcut saveMountKeys = new KeyboardShortcut((KeyCode)115, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }); public static ButtonConfig adjustCustomModeSwitchButton; public static ConfigEntry<bool> teleportMounts; public static ConfigEntry<int> customMountCount; public static Dictionary<string, int> mountNameDict; public static List<ConfigEntry<string>> customMountNames; public static List<ConfigEntry<int>> customMountSaddleTiers; public static List<ConfigEntry<Vector3>> customMountPoints; public static List<ConfigEntry<Vector3>> customSaddlePos; public static List<ConfigEntry<Vector3>> customSaddleScale; public static List<ConfigEntry<Vector3>> customSaddleRot; public static List<ConfigEntry<float>> customMountFlyStamina; public static List<ConfigEntry<float>> customStamina; public static List<ConfigEntry<string>> customTightMountPaths; public static ConfigEntry<Vector3> MountPointAdjustment; private static ConfigEntry<KeyboardShortcut> mountModifierKey; public static ConfigEntry<bool> useBlockforSecondary; public static ConfigEntry<string> saddleNames; public static ConfigEntry<bool> canAttackMounted; public static ConfigEntry<bool> mountsCanDrown; public static GameObject SalObj; public static Dictionary<string, Mount> customMounts = new Dictionary<string, Mount>(); public static Dictionary<string, Mount> removeMounts = new Dictionary<string, Mount>(); public static List<string> LateLoadMounts = new List<string>(); public static List<string> AddFullMountToYaml = new List<string>(); public static List<string> AddJustPathToYaml = new List<string>(); public static string[] TieredSaddleNames = new string[9]; public static Dictionary<string, Mount> legacyMounts = new Dictionary<string, Mount>(); public static Vector3 legacyOffset = new Vector3(0.048f, 0.035f, -0.205f); public static Vector3 legacyScale = new Vector3(1.7f, 0.77f, 1f); public static bool isWritingYML = false; public static bool RecipesMade = false; private static string AssetPath = "Assets/Saddles/"; public static CustomRPC jot_MountlistRPC; public static bool MountUpdate = false; private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00dc: 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_00ea: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Expected O, but got Unknown //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Expected O, but got Unknown //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Expected O, but got Unknown //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Expected O, but got Unknown //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Expected O, but got Unknown //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Expected O, but got Unknown //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Expected O, but got Unknown //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Expected O, but got Unknown //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Expected O, but got Unknown //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Expected O, but got Unknown //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Expected O, but got Unknown //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Expected O, but got Unknown //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Expected O, but got Unknown //IL_0661: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Expected O, but got Unknown //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Expected O, but got Unknown //IL_06cb: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Expected O, but got Unknown //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Expected O, but got Unknown //IL_0739: Unknown result type (might be due to invalid IL or missing references) //IL_0764: Unknown result type (might be due to invalid IL or missing references) //IL_0777: Unknown result type (might be due to invalid IL or missing references) //IL_077c: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Expected O, but got Unknown //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Expected O, but got Unknown //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Unknown result type (might be due to invalid IL or missing references) //IL_07ea: Unknown result type (might be due to invalid IL or missing references) //IL_07f7: Expected O, but got Unknown //IL_07f7: Unknown result type (might be due to invalid IL or missing references) //IL_0801: Expected O, but got Unknown //IL_0886: Unknown result type (might be due to invalid IL or missing references) //IL_088b: Unknown result type (might be due to invalid IL or missing references) //IL_0a03: Unknown result type (might be due to invalid IL or missing references) //IL_0a0d: Expected O, but got Unknown canMountPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Can Mount Player", false, new ConfigDescription("Experimental: Can Players be mounted", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); teleportMounts = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Teleport Mounts", true, new ConfigDescription("Allow Mounts to Teleport with their rider", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); BoarStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Boar Stamina", 60f, new ConfigDescription("Mounted Boar Stamina", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); WolfStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Wolf Stamina", 120f, new ConfigDescription("Mounted Wolf Stamina", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); LoxStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Lox Stamina Override", -1f, new ConfigDescription("Override Lox Stamina, set -1 to not modify", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); AsksvinStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Asksvin Stamina Override", -1f, new ConfigDescription("Override Asksvin Stamina, set -1 to not modify", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); FedStaminaMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Stamina Regen Multiplier", 1f, new ConfigDescription("Multiply stamina regen rate when mount is fed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); MountPointAdjustment = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Micromanagement", "Mount Point Adjustment", Vector3.zero, (ConfigDescription)null); mountModifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Player Mount Modifier Key", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), "This key plus your interact key will attempt to mount another player"); adjustCustom = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Mounts", "Enable Adjust Custom Mounts", false, "Enable Controls to adjust custom mount's mount points and saddle position"); canAttackMounted = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Can Attack Mounted", true, new ConfigDescription("Allow mount to attack using attack keys while mounted", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); mountsCanDrown = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Land Mounts can Drown", true, new ConfigDescription("Do land mounts start to take damage if you run out of stamina when swimming", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); useBlockforSecondary = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Block Key to Perform Secondary", true, new ConfigDescription("Determines if while mounted the block key also performs secondary attack", (AcceptableValueBase)null, Array.Empty<object>())); saddleNames = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Saddle Names", "Tier 1 Saddle,Tier 2 Saddle,Tier 3 Saddle,Tier 4 Saddle,Tier 5 Saddle,Tier 6 Saddle,Tier 7 Saddle,Tier 8 Saddle,", new ConfigDescription("Set the names of the different tiers of Saddle", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); adjustCustomModeSwitch = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Custom Mounts", "Adjust Custom Mount Mode Switch", new KeyboardShortcut((KeyCode)96, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null); customMountCount = ((BaseUnityPlugin)this).Config.Bind<int>("Custom Mounts", "CustomMountCount", 1, new ConfigDescription("Obsolete: Number of Custom Mounts to read from config, add names of creatures to YML", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, int.MaxValue), new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } })); mountNameDict = new Dictionary<string, int>(); customMountNames = new List<ConfigEntry<string>>(); customMountSaddleTiers = new List<ConfigEntry<int>>(); customMountPoints = new List<ConfigEntry<Vector3>>(); customSaddlePos = new List<ConfigEntry<Vector3>>(); customSaddleScale = new List<ConfigEntry<Vector3>>(); customSaddleRot = new List<ConfigEntry<Vector3>>(); customMountFlyStamina = new List<ConfigEntry<float>>(); customStamina = new List<ConfigEntry<float>>(); customTightMountPaths = new List<ConfigEntry<string>>(); logger = ((BaseUnityPlugin)this).Logger; UseFileOpenReadTextWithSystemTextYaml(); Vector3 val = default(Vector3); for (int i = 1; i <= customMountCount.Value; i++) { Mount mount = new Mount(); customMountNames.Add(((BaseUnityPlugin)this).Config.Bind<string>($"Custom Mount {i}", "Name", $"CustomMount {i}", new ConfigDescription("Custom Mount Prefab Name", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mountNameDict.Add(customMountNames[i - 1].Value, i - 1); mount.PrefabName = customMountNames[i - 1].Value; customTightMountPaths.Add(((BaseUnityPlugin)this).Config.Bind<string>($"Custom Mount {i}", "Mount Path", "", new ConfigDescription("Path in Mount Prefab where Saddle and player Mount Point should be placed (example: For the Boar it would be 'CG/Pelvis/Spine/Spine1'", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mount.mountPath = customTightMountPaths[i - 1].Value; ((Vector3)(ref val))..ctor(0f, 1f, 0f); customStamina.Add(((BaseUnityPlugin)this).Config.Bind<float>($"Custom Mount {i}", "Stamina", 120f, new ConfigDescription("Custom Mount Stamina", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mount.stamina = customStamina[i - 1].Value; customMountSaddleTiers.Add(((BaseUnityPlugin)this).Config.Bind<int>($"Custom Mount {i}", "Saddle Tier", 3, new ConfigDescription("Custom Mount Saddle Tier (1=Simple/Boar Saddle, 2=Standard/Wolf Saddle, 3=Advanced/Lox Saddle", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mount.saddleTier = customMountSaddleTiers[i - 1].Value; customMountPoints.Add(((BaseUnityPlugin)this).Config.Bind<Vector3>($"Custom Mount {i}", "Mount Point", val, new ConfigDescription("Point relative to the Mount Path that player should be mounted", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mount.mountPoint = customMountPoints[i - 1].Value; customSaddlePos.Add(((BaseUnityPlugin)this).Config.Bind<Vector3>($"Custom Mount {i}", "Saddle Position", val, new ConfigDescription("Point relative to the Mount Path where the saddle should be placed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mount.saddlePos = customSaddlePos[i - 1].Value; customSaddleScale.Add(((BaseUnityPlugin)this).Config.Bind<Vector3>($"Custom Mount {i}", "Saddle Scale", Vector3.one, new ConfigDescription("Scaling of the saddle", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mount.saddleScale = customSaddleScale[i - 1].Value; customSaddleRot.Add(((BaseUnityPlugin)this).Config.Bind<Vector3>($"Custom Mount {i}", "Saddle Rotation", Vector3.zero, new ConfigDescription("Rotation of the saddle", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mount.saddleRotation = customSaddleRot[i - 1].Value; customMountFlyStamina.Add(((BaseUnityPlugin)this).Config.Bind<float>($"Custom Mount {i}", "Flying Stamina", 0f, new ConfigDescription("Stamina Drain for Flying", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } }))); mount.flyingStamina = customMountFlyStamina[i - 1].Value; if (!customMounts.ContainsKey(customMountNames[i - 1].Value)) { legacyMounts.Add(customMountNames[i - 1].Value, mount); ManualLogSource obj2 = logger; string value = customMountNames[i - 1].Value; Vector3 mountPoint = mount.mountPoint; obj2.LogMessage((object)("added from config=" + value + ", " + ((object)(Vector3)(ref mountPoint)).ToString())); } } if (Directory.GetFiles(Path.GetDirectoryName(Paths.BepInExConfigPath), "MountUpRestored_CustomMounts*.yml").Count() == 0) { create_YML(); } WriteMounts(); logger.LogMessage((object)"Finished loading in custom mounts"); LoadBuiltInMounts(); string text = "List of Mounts: "; foreach (KeyValuePair<string, Mount> customMount in customMounts) { text = text + customMount.Key + ", "; LateLoadMounts.Add(customMount.Key); } logger.LogMessage((object)text.TrimEnd(',', ' ')); Patches.Apply(); PrefabManager.OnVanillaPrefabsAvailable += LoadAssets; PrefabManager.OnVanillaPrefabsAvailable += CreateSaddles; PieceManager.OnPiecesRegistered += SetupMountable; lateLoad = true; SynchronizationManager.OnConfigurationSynchronized += delegate { MountUpdate = true; }; jot_MountlistRPC = NetworkManager.Instance.AddRPC("jot_MountlistRPC", (CoroutineHandler)null, new CoroutineHandler(jot_RPCClientReceive)); SynchronizationManager.Instance.AddInitialSynchronization(jot_MountlistRPC, (Func<ZPackage>)SendInitialConfig); } private void LoadAssets() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown AssetBundle val = AssetUtils.LoadAssetBundleFromResources("mountupassets", typeof(Setup).Assembly); genericSaddlePrefab = (GameObject)val.LoadAsset("Assets/MeldursonAssets/SaddleBase.prefab", typeof(GameObject)); for (int i = 0; i < 9; i++) { tieredSaddlePrefabs[i] = (GameObject)val.LoadAsset(AssetPath + "SaddleT" + i + ".prefab", typeof(GameObject)); PrefabExtension.FixReferences(tieredSaddlePrefabs[i], true); } PrefabManager.OnVanillaPrefabsAvailable -= LoadAssets; } private ZPackage SendInitialConfig() { logger.LogWarning((object)"Sent Client MountList RPC"); CfgPackage cfgPackage = new CfgPackage(); return cfgPackage.PackMountlist(); } private static void LoadBuiltInMounts() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if (!customMounts.ContainsKey("Wolf")) { Mount mount = new Mount(); mount.PrefabName = "Wolf"; mount.mountPath = "WolfSmooth/CG/Pelvis/Spine/Spine1"; mount.mountPoint = wolfMountPos; mount.saddlePos = wolfSaddlePos; mount.saddleTier = 4; mount.stamina = WolfStamina.Value; mount.saddleScale = wolfLocalScale; mount.saddleRotation = Vector3.zero; customMounts.Add("Wolf", mount); logger.LogMessage((object)("added from default=" + mount.PrefabName)); } if (!customMounts.ContainsKey("Boar")) { Mount mount2 = new Mount(); mount2.PrefabName = "Boar"; mount2.mountPath = "CG/Pelvis/Spine/Spine1"; mount2.mountPoint = boarMountPos; mount2.saddlePos = boarSaddlePos; mount2.saddleTier = 1; mount2.stamina = BoarStamina.Value; mount2.saddleScale = boarLocalScale; mount2.saddleRotation = Vector3.zero; customMounts.Add("Boar", mount2); logger.LogMessage((object)("added from default=" + mount2.PrefabName)); } } private IEnumerator jot_RPCClientReceive(long sender, ZPackage package) { logger.LogWarning((object)"Client received MountList RPC"); yield return null; removeMounts = customMounts; CfgPackage.Unpack(package); LateLoadMounts.Clear(); foreach (KeyValuePair<string, Mount> key in customMounts) { LateLoadMounts.Add(key.Key); } SetupMountable(fromServer: true); } public static void writeYML() { logger.LogWarning((object)"Writing to YML"); if (!ZNet.instance.IsServer()) { logger.LogWarning((object)"not Server, cancelling WriteYML"); } else { if (isWritingYML) { return; } try { isWritingYML = true; if (AddFullMountToYaml.Count <= 0) { isWritingYML = false; return; } WriteMounts(); isWritingYML = false; } catch { logger.LogWarning((object)"Error in Writing YML"); isWritingYML = false; } isWritingYML = false; } } public static List<Mount> ParseMounts(string ymlContents) { Parser parser = new Parser(new StringReader(ymlContents)); IDeserializer deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); parser.Consume<YamlDotNet.Core.Events.StreamStart>(); if (!parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out var _)) { return new List<Mount>(); } parser.Consume<MappingStart>(); List<Mount> list = new List<Mount>(); YamlDotNet.Core.Events.Scalar event2; while (parser.TryConsume<YamlDotNet.Core.Events.Scalar>(out event2)) { try { Mount mount; if (parser.Current.GetType() != typeof(MappingStart)) { if ((event2.Value ?? "") == "") { continue; } mount = new Mount(); goto IL_00c5; } mount = new Mount(deserializer.Deserialize<MountSerialized>(parser)); goto IL_00c5; IL_00c5: if ((mount.PrefabName ?? "") == "") { mount.PrefabName = event2.Value; } list.Add(mount); } catch { logger.LogWarning((object)("Failed to parse " + event2.Value + " from yaml, check to make sure this prefab is formated correctly")); } } return list; } public static string formatMountYML(string mountYML, string prefabName) { mountYML = mountYML.Replace("\n", "\n ").Replace("'", ""); if (mountYML.StartsWith("prefabName:")) { mountYML = mountYML.Remove(0, mountYML.IndexOf("\n") + 1); } return prefabName + ":\n" + mountYML + "\n"; } public static bool create_YML() { string[] files = Directory.GetFiles(Path.GetDirectoryName(Paths.BepInExConfigPath), "MountUpRestored_CustomMounts*.yml"); if (files.Count() > 0) { logger.LogError((object)"There are already MountUpRestored_CustomMounts in your config folder, check to make sure they are formatted correctly"); logger.LogError((object)"The files are:"); string[] array = files; foreach (string text in array) { logger.LogError((object)text); } return false; } string path = Path.Combine(Path.GetDirectoryName(Paths.BepInExConfigPath), Path.GetFileName("MountUpRestored_CustomMounts.yml")); File.Create(path).Dispose(); string contents = "# To start setup for mounting a creature, add the creature prefab name on its own line followed by a colon : such as\nPrefabName:\n# Once loading into the game and coming across this creature it will attempt to snap the saddle to the correct bone and complete the rest of the config in this file\n# By default the required saddle is a Tier 3 saddle (Advanced Saddle) that you will need to use on the creature to mount it.\n# To adjust the mounting location you will need to set Enable Adjust Custom Mounts = true in meldurson.MountUpRestored.cfg\n# You can also find a bunch of premade configurations https://thunderstore.io/c/valheim/p/Meldurson/MountUpRestored/wiki/1368-premade-configs/ that you can copy/paste parts into this file, or paste the entire config into your config folder\n\n"; File.AppendAllText(path, contents); return true; } public static void WriteMounts() { if (AddFullMountToYaml.Count <= 0) { return; } string[] files = Directory.GetFiles(Path.GetDirectoryName(Paths.BepInExConfigPath), "MountUpRestored_CustomMounts*.yml"); if (files.Count() > 0) { ISerializer serializer = new SerializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); string[] array = files; foreach (string path in array) { string text = File.ReadAllText(path); if ((text.Trim(' ', '\n', '\t') ?? "") == "") { continue; } Parser parser = new Parser(new StringReader(text)); parser.Consume<YamlDotNet.Core.Events.StreamStart>(); if (!parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out var _)) { continue; } parser.Consume<MappingStart>(); int num = 0; bool flag = false; bool flag2 = false; YamlDotNet.Core.Events.Scalar event2; while (parser.TryConsume<YamlDotNet.Core.Events.Scalar>(out event2)) { if (flag) { for (int j = 0; j < num; j++) { parser.SkipThisAndNestedEvents(); if (!parser.TryConsume<YamlDotNet.Core.Events.Scalar>(out var event3)) { flag2 = true; } else { event2 = event3; } } } if (flag2) { break; } flag = false; num++; try { if (!AddFullMountToYaml.Contains(event2.Value)) { parser.SkipThisAndNestedEvents(); continue; } if (!customMounts.TryGetValue(event2.Value, out var value)) { logger.LogWarning((object)("Could not find" + event2.Value + "in MountsToOverwrite, skipping write")); parser.SkipThisAndNestedEvents(); continue; } MountToYaml graph = new MountToYaml(value); string value2 = formatMountYML(serializer.Serialize(graph), event2.Value); parser.SkipThisAndNestedEvents(); string text2 = text.Remove(event2.Start.Index, parser.Current.Start.Index - 1 - event2.Start.Index).Insert(event2.Start.Index, value2); text = text2; AddFullMountToYaml.Remove(event2.Value); parser = new Parser(new StringReader(text)); flag = true; parser.Consume<YamlDotNet.Core.Events.StreamStart>(); parser.Consume<YamlDotNet.Core.Events.DocumentStart>(); parser.Consume<MappingStart>(); } catch { logger.LogWarning((object)("Failed to parse " + event2.Value + " from yaml, check to make sure this prefab is formated correctly")); } } File.WriteAllText(path, text); logger.LogMessage((object)"Overwrote existing creatures to yaml"); } if (AddFullMountToYaml.Count <= 0) { return; } string text3 = "\n"; foreach (string item in AddFullMountToYaml) { if (!customMounts.TryGetValue(item, out var value3)) { logger.LogWarning((object)("Could not find" + item + "in MountsToOverwrite, skipping write")); continue; } logger.LogWarning((object)("writing " + item + " to " + files[0])); string text4 = formatMountYML(serializer.Serialize(new MountToYaml(value3)), item); text3 += text4; } File.AppendAllText(files[0], text3); logger.LogWarning((object)"Saved creatures to YML"); } else { logger.LogWarning((object)"no MountList files, creating one"); if (create_YML()) { WriteMounts(); } } } public static List<Mount> UseFileOpenReadTextWithSystemTextYaml() { string[] files = Directory.GetFiles(Path.GetDirectoryName(Paths.BepInExConfigPath), "MountUpRestored_CustomMounts*.yml"); List<Mount> list = new List<Mount>(); if (files.Count() > 0) { string[] array = files; foreach (string path in array) { string ymlContents = File.ReadAllText(path); List<Mount> list2 = ParseMounts(ymlContents); if (list2[0].PrefabName == "PrefabName") { list2.RemoveAt(0); } foreach (Mount mount in list2) { if (!list.Exists((Mount x) => x.PrefabName == mount.PrefabName) && !((mount.PrefabName ?? "") == "")) { list.Add(mount); if (!customMounts.ContainsKey(mount.PrefabName)) { customMounts.Add(mount.PrefabName, mount); } } } } } else { logger.LogWarning((object)"no config files"); } return list; } public static string StringVec(Vector3 vec) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return $"{{\"x\":{vec.x:F2},\"y\":{vec.y:F2},\"z\":{vec.z:F2}" + "}"; } public static void MakeMountable(Tameable tame, bool legacy = false) { string name = ((Object)tame).name; bool flag = false; if (name == "Lox") { return; } Mount value2; if (customMounts.TryGetValue(name, out var value)) { logger.LogMessage((object)("Making " + ((Object)tame).name + " Mountable" + (legacy ? "(legacy)" : ""))); if (int.TryParse(value.customSaddle, out var result) && result <= 8 && result >= 0) { tame.m_saddleItem = tieredSaddleItems[result]; } else { bool flag2 = false; if ((value.customSaddle ?? "") != "") { GameObject prefab = PrefabManager.Instance.GetPrefab(value.customSaddle); if (Object.op_Implicit((Object)(object)prefab)) { ItemDrop saddleItem = default(ItemDrop); if (prefab.TryGetComponent<ItemDrop>(ref saddleItem)) { tame.m_saddleItem = saddleItem; flag2 = true; logger.LogInfo((object)("Set custom Saddle: " + value.customSaddle + " for " + name)); } else { logger.LogWarning((object)("Unable to find itemDrop in object :" + value.customSaddle + " to use as a custom saddle item for " + name + ". Please make sure to use the an items prefab name")); } } else { logger.LogWarning((object)("Unable to find GameObject :" + value.customSaddle + " to use as a custom saddle item for " + name + ". Please make sure to use the prefab name")); } } if (!flag2) { result = ((value.saddleTier == 0) ? 5 : value.saddleTier); tame.m_saddleItem = tieredSaddleItems[result]; } } flag = true; LateLoadMounts.Remove(name); } else if (removeMounts.TryGetValue(name, out value2)) { tame.m_saddleItem = null; Mountable mountable = default(Mountable); if (((Component)tame).gameObject.TryGetComponent<Mountable>(ref mountable)) { logger.LogWarning((object)("removed " + name + " from mountable")); Object.DestroyImmediate((Object)(object)mountable); } return; } if ((Object)(object)((Component)tame).gameObject.GetComponent<Mountable>() == (Object)null) { if (legacy) { ((Component)tame).gameObject.AddComponent<Mountable_L>().Type = name; } else if (flag) { ((Component)tame).gameObject.AddComponent<Mountable>().Type = name; } } } private static void SetupMountable() { SetupMountable(fromServer: false); } private static void SetupMountable(bool fromServer = false) { if (!fromServer && !ZNet.instance.IsServer()) { logger.LogMessage((object)"Not Server, will wait for RPC"); return; } if (LateLoadMounts.Count > 0) { for (int num = LateLoadMounts.Count - 1; num >= 0; num--) { bool flag = true; logger.LogMessage((object)("Late mount load for " + LateLoadMounts[num])); GameObject prefab = PrefabManager.Instance.GetPrefab(LateLoadMounts[num]); if ((Object)(object)prefab == (Object)null) { logger.LogWarning((object)("Go is null for " + LateLoadMounts[num])); } else { Tameable val = prefab.GetComponent<Tameable>(); if (lateLoad && (Object)(object)val == (Object)null && ((Object)prefab).name.StartsWith("RRR")) { logger.LogMessage((object)("RRRCompat Mounting for " + LateLoadMounts[num])); RRRCompat.tryAddTameable(prefab); val = prefab.GetComponent<Tameable>(); } if ((Object)(object)val == (Object)null) { if ((Object)(object)prefab.GetComponent<MonsterAI>() == (Object)null) { logger.LogWarning((object)(LateLoadMounts[num] + " cannot be mounted as does not have a MonsterAI")); flag = false; } else { logger.LogWarning((object)("Manually added Tameable for " + LateLoadMounts[num])); val = prefab.AddComponent<Tameable>(); } } if (flag) { MakeMountable(val); } } } } if (LoxStamina.Value != -1f) { SetMountStamina(PrefabManager.Instance.GetPrefab("Lox"), LoxStamina.Value); } if (AsksvinStamina.Value != -1f) { SetMountStamina(PrefabManager.Instance.GetPrefab("Asksvin"), AsksvinStamina.Value); } UpdateSaddleDesc(); PieceManager.OnPiecesRegistered -= SetupMountable; } public static void SetMountStamina(GameObject go, float newStam) { Tameable val = default(Tameable); if (!((Object)(object)go == (Object)null) && go.TryGetComponent<Tameable>(ref val) && !((Object)(object)val.m_saddle == (Object)null)) { logger.LogWarning((object)("Set Stamina of " + ((Object)go).name + " to " + newStam)); val.m_saddle.m_maxStamina = newStam; } } private static void RemoveMounts() { Tameable[] array = (from m in Resources.FindObjectsOfTypeAll<Tameable>() where !((Object)m).name.Contains("(Clone)") select m).ToArray(); Mountable mountable = default(Mountable); for (int i = 0; i < array.Length; i++) { if (((Component)array[i]).gameObject.TryGetComponent<Mountable>(ref mountable)) { Debug.Log((object)("Clearing mountable from " + ((Object)array[i]).name)); Object.DestroyImmediate((Object)(object)mountable); array[i].m_saddleItem = null; } } PieceManager.OnPiecesRegistered += SetupMountable; } public static void ResetAllMounts() { RemoveMounts(); customMounts.Clear(); removeMounts.Clear(); UseFileOpenReadTextWithSystemTextYaml(); LoadBuiltInMounts(); LateLoadMounts.Clear(); foreach (KeyValuePair<string, Mount> customMount in customMounts) { LateLoadMounts.Add(customMount.Key); } } public static void CreateSaddles() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown for (int i = 0; i < tieredSaddlePrefabs.Length; i++) { string description = "No current creatures can be mounted with this saddle (an error might have occurred)"; CustomItem item = ItemManager.Instance.GetItem("SaddleT" + i); if (item != null) { item.ItemDrop.m_itemData.m_shared.m_description = description; continue; } CustomItem val = new CustomItem(((Component)tieredSaddlePrefabs[i].transform.GetChild(1)).gameObject, true, CreateRecipes(i)); ItemManager.Instance.AddItem(val); tieredSaddleItems[i] = val.ItemDrop; val.ItemDrop.m_itemData.m_shared.m_name = "Tier " + i + " Saddle"; val.ItemDrop.m_itemData.m_dropPrefab = tieredSaddlePrefabs[i]; val.ItemDrop.m_itemData.m_shared.m_weight = 5f + (float)i; val.ItemDrop.m_itemData.m_shared.m_description = description; } PrefabManager.OnVanillaPrefabsAvailable -= CreateSaddles; if (!RecipesMade) { RecipesMade = true; } } public static void UpdateSaddleDesc() { //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Expected O, but got Unknown List<string>[] array = new List<string>[9]; for (int i = 0; i < array.Length; i++) { array[i] = new List<string>(); } Character val = default(Character); foreach (KeyValuePair<string, Mount> customMount in customMounts) { int result = -1; GameObject prefab = PrefabManager.Instance.GetPrefab(customMount.Key); string text = customMount.Key; if ((Object)(object)prefab == (Object)null) { Debug.LogWarning((object)("go null for " + text + " skipping")); continue; } if (prefab.TryGetComponent<Character>(ref val)) { text = val.m_name; } string text2 = customMount.Value.customSaddle ?? ""; if (int.TryParse(text2, out result) || result > 8 || result < 0) { array[result].Add(text); } else if (text2.Length > 1) { if (text2.Contains("SaddleT")) { string text3 = text2.Substring(7, text2.Length - 7); Debug.Log((object)(customMount.Key + " has custom saddle with tier " + text3)); if (int.TryParse(text3, out var result2) && result2 <= 8 && result2 >= 0) { customMount.Value.customSaddle = text3; array[result2].Add(text); } } } else { result = ((customMount.Value.saddleTier == 0) ? 5 : customMount.Value.saddleTier); array[result].Add(text); } } TieredSaddleNames = saddleNames.Value.Split(new char[1] { ',' }); for (int j = 0; j < array.Length; j++) { string text4 = "A smaller simpler saddle, it should be good for smaller calmer creatures such as "; if (j > 4) { text4 = "A well-made, sturdy saddle. It should be good for fiercer creatures such as "; } else if (j > 2) { text4 = "Well crafted saddle able to ride strong creatures such as "; } text4 += string.Join(", ", array[j]); text4 = text4.TrimEnd(',', ' '); CustomItem item = ItemManager.Instance.GetItem("SaddleT" + j); if (item != null) { Debug.Log((object)("Updating Saddle item for Tier " + j)); item.ItemDrop.m_itemData.m_shared.m_description = text4; if (j > 0) { item.Recipe.Recipe.m_enabled = array[j].Count > 0; if (j <= TieredSaddleNames.Length) { item.ItemDrop.m_itemData.m_shared.m_name = TieredSaddleNames[j - 1]; } } continue; } item = new CustomItem(((Component)tieredSaddlePrefabs[j].transform.GetChild(1)).gameObject, true, CreateRecipes(j)); if (array[j].Count == 0) { text4 = text4.Replace(" such as", "."); } ItemManager.Instance.AddItem(item); tieredSaddleItems[j] = item.ItemDrop; if (j < array.Length) { item.ItemDrop.m_itemData.m_shared.m_name = TieredSaddleNames[j - 1]; } else { item.ItemDrop.m_itemData.m_shared.m_name = "Tier " + j + " Saddle"; } item.ItemDrop.m_itemData.m_dropPrefab = tieredSaddlePrefabs[j]; item.ItemDrop.m_itemData.m_shared.m_weight = 5f + (float)j; item.ItemDrop.m_itemData.m_shared.m_description = text4; } if (!RecipesMade) { RecipesMade = true; } } private static ItemConfig CreateRecipes(int recipeNum) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected O, but got Unknown //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Expected O, but got Unknown //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Expected O, but got Unknown //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Expected O, but got Unknown //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected O, but got Unknown //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Expected O, but got Unknown //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Expected O, but got Unknown //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown ItemConfig val = new ItemConfig(); switch (recipeNum) { case 1: val.AddRequirement(new RequirementConfig("LeatherScraps", 6, 0, false)); val.AddRequirement(new RequirementConfig("DeerHide", 4, 0, false)); val.AddRequirement(new RequirementConfig("HardAntler", 2, 0, false)); val.AddRequirement(new RequirementConfig("Dandelion", 10, 0, false)); val.CraftingStation = CraftingStations.Workbench; val.MinStationLevel = 1; break; case 2: val.AddRequirement(new RequirementConfig("TrollHide", 6, 0, false)); val.AddRequirement(new RequirementConfig("DeerHide", 4, 0, false)); val.AddRequirement(new RequirementConfig("Bronze", 4, 0, false)); val.AddRequirement(new RequirementConfig("AncientSeed", 3, 0, false)); val.CraftingStation = CraftingStations.Forge; val.MinStationLevel = 1; break; case 3: val.AddRequirement(new RequirementConfig("DeerHide", 15, 0, false)); val.AddRequirement(new RequirementConfig("ElderBark", 10, 0, false)); val.AddRequirement(new RequirementConfig("Iron", 6, 0, false)); val.AddRequirement(new RequirementConfig("Guck", 10, 0, false)); val.CraftingStation = CraftingStations.Forge; val.MinStationLevel = 2; break; case 4: val.AddRequirement(new RequirementConfig("WolfPelt", 6, 0, false)); val.AddRequirement(new RequirementConfig("DeerHide", 4, 0, false)); val.AddRequirement(new RequirementConfig("Obsidian", 2, 0, false)); val.AddRequirement(new RequirementConfig("Silver", 5, 0, false)); val.AddRequirement(new RequirementConfig("FreezeGland", 10, 0, false)); val.CraftingStation = CraftingStations.Workbench; val.MinStationLevel = 4; break; case 5: val.AddRequirement(new RequirementConfig("LoxPelt", 6, 0, false)); val.AddRequirement(new RequirementConfig("DeerHide", 4, 0, false)); val.AddRequirement(new RequirementConfig("BlackMetal", 4, 0, false)); val.AddRequirement(new RequirementConfig("TrophyLox", 1, 0, false)); val.AddRequirement(new RequirementConfig("Tar", 5, 0, false)); val.CraftingStation = CraftingStations.Forge; val.MinStationLevel = 3; break; case 6: val.AddRequirement(new RequirementConfig("ScaleHide", 15, 0, false)); val.AddRequirement(new RequirementConfig("Obsidian", 6, 0, false)); val.AddRequirement(new RequirementConfig("YggdrasilWood", 6, 0, false)); val.AddRequirement(new RequirementConfig("Sap", 10, 0, false)); val.AddRequirement(new RequirementConfig("Eitr", 3, 0, false)); val.CraftingStation = CraftingStations.Workbench; val.MinStationLevel = 5; break; case 7: val.AddRequirement(new RequirementConfig("LoxPelt", 10, 0, false)); val.AddRequirement(new RequirementConfig("MorgenHeart", 2, 0, false)); val.AddRequirement(new RequirementConfig("Flametal", 6, 0, false)); val.AddRequirement(new RequirementConfig("Tar", 5, 0, false)); val.CraftingStation = CraftingStations.Forge; val.MinStationLevel = 4; break; case 8: val.AddRequirement(new RequirementConfig("WolfPelt", 20, 0, false)); val.AddRequirement(new RequirementConfig("ScaleHide", 10, 0, false)); val.AddRequirement(new RequirementConfig("GemstoneBlue", 1, 0, false)); val.AddRequirement(new RequirementConfig("FreezeGland", 50, 0, false)); val.CraftingStation = CraftingStations.ArtisanTable; val.MinStationLevel = 2; break; } return val; } } namespace MountUp { internal class AdjustmentPatches { [HarmonyPatch(typeof(Character), "GetHoverText")] [HarmonyPostfix] private static void Char_GetHoverText(Character __instance, ref string __result) { //IL_0089: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) Mountable mountable = default(Mountable); if (!__instance.m_tamed || !((Component)__instance).gameObject.TryGetComponent<Mountable>(ref mountable)) { return; } mountable.updateLocation(); if (!Setup.adjustCustom.Value || !ZNet.instance.IsServer() || (Object)(object)mountable.getSaddle() == (Object)null || !mountable.getSaddle().activeSelf) { return; } KeyboardShortcut val = new KeyboardShortcut((KeyCode)101, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }); if (((KeyboardShortcut)(ref val)).IsDown()) { Player localPlayer = Player.m_localPlayer; Sadle component = mountable.getSaddle().GetComponent<Sadle>(); if ((Object)(object)component != (Object)null && (Object)(object)localPlayer != (Object)null) { Debug.LogWarning((object)"Attempt Force Mount"); ZNetView nview = component.m_nview; object[] array = new object[1]; ZDOID zDOID = ((Character)localPlayer).GetZDOID(); array[0] = ((ZDOID)(ref zDOID)).UserID; nview.InvokeRPC("RequestControl", array); } } string text = Localization.instance.Localize("$hud_rename"); __result = __result.Replace(text, text + "\n[<color=orange><b>Alt+E</b></color>] Sit in Saddle"); } } [Serializable] public class CfgPackage { public MountSerialized[] mounts; public static ZPackage zpack; public ZPackage PackMountlist() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (zpack == null) { Pack(); Setup.logger.LogWarning((object)"Packed List"); } else { Setup.logger.LogWarning((object)"Already Packed List"); } ZPackage val = new ZPackage(); return zpack; } public ZPackage Pack() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown mounts = new MountSerialized[Setup.customMounts.Count]; int num = 0; foreach (KeyValuePair<string, Mount> customMount in Setup.customMounts) { mounts[num] = new MountSerialized(customMount.Value); num++; } MountSerialized[] array = mounts; foreach (MountSerialized mountSerialized in array) { Setup.logger.LogWarning((object)("mount in list=" + mountSerialized.PrefabName)); } ZPackage val = new ZPackage(); using MemoryStream memoryStream = new MemoryStream(); using (GZipStream serializationStream = new GZipStream(memoryStream, CompressionLevel.Optimal)) { new BinaryFormatter().Serialize(serializationStream, this); } byte[] buffer = memoryStream.GetBuffer(); val.Write(buffer); zpack = val; return val; } public static void Unpack(ZPackage package, bool setValue = true) { byte[] buffer = package.ReadByteArray(); using MemoryStream stream = new MemoryStream(buffer); using GZipStream serializationStream = new GZipStream(stream, CompressionMode.Decompress, leaveOpen: true); if (new BinaryFormatter().Deserialize(serializationStream) is CfgPackage cfgPackage) { Setup.logger.LogMessage((object)"Unpackaging MountUp Configs."); MountSerialized[] array = cfgPackage.mounts; Setup.removeMounts = new Dictionary<string, Mount>(Setup.customMounts); Setup.customMounts.Clear(); MountSerialized[] array2 = array; foreach (MountSerialized mountSerialized in array2) { Setup.logger.LogMessage((object)("mount=" + mountSerialized.PrefabName)); Setup.customMounts.Add(mountSerialized.PrefabName, new Mount(mountSerialized)); } Setup.logger.LogMessage((object)"Successfully unpacked configs."); } else { Setup.logger.LogWarning((object)"Received bad config package. Unable to load."); } } } public class Mountable : MonoBehaviour { public GameObject mountPoint; private Transform mountPointBase; private GameObject saddle; private float flyStaminaDrain = 10f; public bool canfly = false; private Animator anim; public string Type; public static ManualLogSource logger; public Vector3 basePos; private static Vector3 rotationAdjust = Setup.rotationAdjust; private static Vector3 posDefault = Setup.posDefault; public int[] attackorder = new int[4]; private bool initAttacks = false; private bool setCustomAttacks = false; private float lastSaddleScale = 0f; public ZNetView m_nview; public void Awake() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_0759: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_087b: Unknown result type (might be due to invalid IL or missing references) //IL_088a: Unknown result type (might be due to invalid IL or missing references) //IL_08b5: Unknown result type (might be due to invalid IL or missing references) //IL_08b7: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_08d8: Unknown result type (might be due to invalid IL or missing references) //IL_08de: Unknown result type (might be due to invalid IL or missing references) //IL_08e3: Unknown result type (might be due to invalid IL or missing references) //IL_08e8: Unknown result type (might be due to invalid IL or missing references) //IL_08f4: Unknown result type (might be due to invalid IL or missing references) //IL_08cf: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_098f: Unknown result type (might be due to invalid IL or missing references) //IL_09a2: Unknown result type (might be due to invalid IL or missing references) //IL_09b5: Unknown result type (might be due to invalid IL or missing references) //IL_09c8: Unknown result type (might be due to invalid IL or missing references) //IL_09d8: Unknown result type (might be due to invalid IL or missing references) //IL_09ed: Unknown result type (might be due to invalid IL or missing references) //IL_09fe: Unknown result type (might be due to invalid IL or missing references) //IL_0a03: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_0a0d: Unknown result type (might be due to invalid IL or missing references) //IL_0a1f: Unknown result type (might be due to invalid IL or missing references) if (logger == null) { logger = Setup.logger; } Tameable component = ((Component)this).GetComponent<Tameable>(); Type = ((Object)component).name.Replace("(Clone)", ""); Humanoid component2 = ((Component)this).gameObject.GetComponent<Humanoid>(); Transform val = ((Component)component2).gameObject.transform.Find("Visual"); mountPoint = new GameObject("MountPoint"); mountPoint.transform.parent = val; mountPoint.transform.rotation = ((Component)this).transform.rotation; Vector3 val2 = posDefault; Vector3 val3 = posDefault; Vector3 one = Vector3.one; Vector3 val4 = rotationAdjust; m_nview = ((Component)this).gameObject.GetComponent<ZNetView>(); m_nview.Register("RPC_SetMountPoint", (Action<long>)RPC_SetMountPoint); if (!Setup.customMounts.TryGetValue(Type, out var value)) { logger.LogWarning((object)(Type + " is not in custom mounts list, removing mountable")); Object.Destroy((Object)(object)this); return; } string text = value.mountPath ?? ""; if (text.Contains("\\")) { logger.LogWarning((object)(Type + " Mount Path should use '/' rather than '\\', trying to replace")); text.Replace('\\', '/'); value.mountPath = text; } if (text != "") { mountPointBase = val.Find(text); } val2 = (basePos = value.mountPoint); val3 = value.saddlePos; one = value.saddleScale; val4 = value.saddleRotation + rotationAdjust; if ((Object)(object)mountPointBase == (Object)null) { string[] array; if (!(text == "")) { mountPoint.transform.parent = val; string text2 = ""; array = text.Split(new char[1] { '/' }); string[] array2 = array; foreach (string text3 in array2) { if (!text2.Equals("")) { text2 += "/"; } if ((Object)(object)val.Find(text2 + text3) == (Object)null) { string text4 = Type + " Mount Path '" + text + "' is not correct. "; if (text2 != "") { text4 = text4 + "'" + text2 + "' appears to work. "; } text4 = text4 + text3 + " cannot be found in " + Type + " body. " + Type + " will not be rideable."; ((Component)component2).GetComponent<Tameable>().m_saddleItem = null; logger.LogError((object)text4); return; } text2 += text3; } logger.LogError((object)("Unknown error in setting up saddle and riding for " + Type + ", it will not be rideable")); ((Component)component2).GetComponent<Tameable>().m_saddleItem = null; return; } Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(); string[] array3 = new string[7] { "spine2", "spine1", "tail2", "spine", "neck", "head", "armature" }; List<string> list = new List<string>(); array = array3; string[] array4 = array; foreach (string text5 in array4) { Transform[] array5 = componentsInChildren; Transform[] array6 = array5; foreach (Transform val5 in array6) { if (((Object)val5).name.ToLowerInvariant() == text5) { Transform val6 = val5; if (text5 == "neck") { val6 = val6.parent; } if ((Object)(object)mountPointBase == (Object)null) { mountPointBase = val6; text = GetPath(val6); } else if (text5 != "armature") { list.Add(GetPath(val6)); } break; } } } if ((Object)(object)mountPointBase == (Object)null) { array = array3; string[] array7 = array; foreach (string value2 in array7) { Transform[] array8 = componentsInChildren; Transform[] array9 = array8; foreach (Transform val7 in array9) { string text6 = ((Object)val7).name.ToLowerInvariant(); if (text6.StartsWith(value2) || text6.EndsWith(value2)) { if ((Object)(object)mountPointBase == (Object)null) { mountPointBase = val7; text = GetPath(val7); } else { list.Add(GetPath(val7)); } break; } } } } if (!((Object)(object)mountPointBase != (Object)null)) { logger.LogError((object)("Could not find potential Mount Path for " + Type + ". " + Type + " will not be rideable")); ((Component)component2).GetComponent<Tameable>().m_saddleItem = null; return; } string text7 = ""; if (list.Count > 0) { text7 = "\nPossible Alternatives:"; foreach (string item in list) { text7 = text7 + "\n" + item; } } value.mountPath = text; if (value.saddleRotation == Vector3.zero) { mountPoint.transform.rotation = mountPointBase.rotation; value.saddleRotation = mountPoint.transform.localEulerAngles - Setup.rotationAdjust; val4 = value.saddleRotation + Setup.rotationAdjust; } logger.LogMessage((object)("Found potential Mount Path for " + Type + ": " + text + text7)); Setup.AddFullMountToYaml.Add(value.PrefabName); ((MonoBehaviour)this).Invoke("UpdateConfig", 5f); } mountPoint.transform.parent = val; saddle = Object.Instantiate<GameObject>(((Component)Setup.tieredSaddlePrefabs[value.saddleTier].transform.GetChild(0)).gameObject, val); mountPoint.transform.localEulerAngles = val4; saddle.transform.localEulerAngles = val4; saddle.GetComponent<Sadle>().m_maxStamina = value.stamina; flyStaminaDrain = value.flyingStamina; BaseAI baseAI = ((Character)component2).GetBaseAI(); MonsterAI val8 = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null); if ((Object)(object)val8 != (Object)null && val8.m_avoidLand) { saddle.GetComponent<Sadle>().m_swimStaminaDrain = 0f; } if (((Character)component2).IsFlying()) { if (flyStaminaDrain < 0f) { flyStaminaDrain = 1f; } canfly = true; } else if (flyStaminaDrain > 0f) { canfly = true; } Sadle component3 = saddle.GetComponent<Sadle>(); component3.m_hoverText = ((Character)component2).m_name + " Saddle"; component3.m_attachPoint = mountPoint.transform; saddle.SetActive(false); component.m_saddle = component3; ((Component)component3).transform.localPosition = val3; ((Component)component3).transform.localScale = one; if (Setup.adjustCustom.Value) { anim = ((Component)component2).gameObject.GetComponentInChildren<Animator>(); } if (val4 != rotationAdjust) { ((Component)component3).GetComponentInChildren<Transform>().localEulerAngles = val4; } val2 += Setup.MountPointAdjustment.Value; mountPoint.transform.localPosition = val2; if ((Object)(object)component.m_saddle != (Object)null) { component.m_nview.Register("AddSaddle", (Action<long>)component.RPC_AddSaddle); component.m_nview.Register<bool>("SetSaddle", (Action<long, bool>)component.RPC_SetSaddle); component.SetSaddle(component.HaveSaddle()); } mountPoint.transform.parent = mountPointBase; saddle.transform.parent = mountPointBase; mountPoint.transform.localEulerAngles = val4; saddle.transform.localEulerAngles = val4; mountPoint.transform.localPosition = val2; Transform transform = mountPoint.transform; transform.position -= mountPoint.transform.rotation * (MountUp.lossyfactor * (saddle.transform.lossyScale.z - 1f) * Vector3.forward); ((Component)component3).transform.localPosition = val3; SphereCollider component4 = saddle.GetComponent<SphereCollider>(); if (!((value.customAttackOrder ?? "") != "")) { return; } string[] array10 = value.customAttackOrder.Split(new char[1] { ',' }); int num = Math.Min(4, array10.Length); for (int n = 0; n < num; n++) { if (int.TryParse(array10[n], out var result)) { attackorder[n] = result; logger.LogInfo((object)("Set Attack Num to " + result)); } else { logger.LogWarning((object)("Failed to set custom attack order for " + array10[n])); } } setCustomAttacks = true; } public void setattacks(Humanoid humanoid) { if (humanoid.m_inventory != null) { List<ItemData> inventory = humanoid.m_inventory.m_inventory; bool[] array = new bool[4]; bool flag = true; if (setCustomAttacks) { for (int i = 0; i < attackorder.Length; i++) { if (attackorder[i] >= inventory.Count) { logger.LogWarning((object)(attackorder[i] + " is higher than the total array of attacks (" + (inventory.Count - 1) + "), please reduce the number")); flag = false; } } if (flag) { initAttacks = true; return; } } for (int j = 0; j < inventory.Count; j++) { float totalDamage = ((DamageTypes)(ref inventory[j].m_shared.m_damages)).GetTotalDamage(); if (totalDamage <= 0f) { continue; } if (inventory[j].m_shared.m_aiWhenFlying) { if (!array[2]) { attackorder[2] = j; array[2] = true; continue; } if (array[3]) { if (((DamageTypes)(ref inventory[attackorder[3]].m_shared.m_damages)).GetTotalDamage() < totalDamage) { attackorder[3] = j; } continue; } if (((DamageTypes)(ref inventory[attackorder[2]].m_shared.m_damages)).GetTotalDamage() > totalDamage) { attackorder[3] = attackorder[2]; attackorder[2] = j; } else { attackorder[3] = j; } array[3] = true; } else if (!array[0]) { attackorder[0] = j; array[0] = true; } else if (array[1]) { if (((DamageTypes)(ref inventory[attackorder[1]].m_shared.m_damages)).GetTotalDamage() < totalDamage) { attackorder[1] = j; } } else { if (((DamageTypes)(ref inventory[attackorder[0]].m_shared.m_damages)).GetTotalDamage() > totalDamage) { attackorder[1] = attackorder[0]; attackorder[0] = j; } else { attackorder[1] = j; } array[1] = true; } } if (!array[3]) { attackorder[3] = attackorder[2]; } if (!array[0] & array[2]) { attackorder[0] = attackorder[2]; if (array[3]) { attackorder[1] = attackorder[3]; array[1] = true; } } if (!array[1]) { attackorder[1] = attackorder[0]; } initAttacks = true; } else { Debug.LogWarning((object)"Creature does not have attacks"); } } public void updateLocation() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Transform transform = mountPoint.transform; float z = getSaddle().transform.lossyScale.z; if (!(Math.Abs(getSaddle().transform.lossyScale.z - lastSaddleScale) < 0.001f)) { lastSaddleScale = z; Debug.LogWarning((object)("new saddle Scale =" + z)); m_nview.InvokeRPC("RPC_SetMountPoint", Array.Empty<object>()); } } public void RPC_SetMountPoint(long sender) { //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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) Debug.LogWarning((object)"in RPC"); Transform transform = mountPoint.transform; Vector3 localPosition = transform.localPosition; Debug.LogWarning((object)("current mountpoint =" + ((object)(Vector3)(ref localPosition)).ToString())); transform.localPosition = basePos; transform.position -= ((Component)transform).transform.rotation * (MountUp.lossyfactor * (getSaddle().transform.lossyScale.z - 1f) * Vector3.forward); } public bool hasInitAttacks() { return initAttacks; } public void setAnimation(bool isAnimating) { if ((Object)(object)anim != (Object)null) { ((Behaviour)anim).enabled = isAnimating; } } public float getFlyStaminaDrain() { return flyStaminaDrain; } public GameObject getSaddle() { return saddle; } public void reduceflyingStamina(float dt) { Character component = ((Component)this).gameObject.GetComponent<Character>(); if (Object.op_Implicit((Object)(object)component) && component.m_flying) { float stamina = saddle.GetComponent<Sadle>().GetStamina(); saddle.GetComponent<Sadle>().SetStamina(stamina - dt * flyStaminaDrain); } } public void ResetMountPoint() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) bool flag = false; if (!Object.op_Implicit((Object)(object)mountPoint)) { Debug.Log((object)"mountPoint null"); flag = true; } if ((Object)(object)saddle == (Object)null) { Debug.Log((object)"saddle null"); flag = true; } if (flag) { logger.LogWarning((object)("Exiting LevelEffect Reset for " + ((Object)((Component)this).gameObject).name)); return; } Transform transform = mountPoint.transform; transform.position -= mountPoint.transform.rotation * (MountUp.lossyfactor * (saddle.transform.lossyScale.z - 1f) * Vector3.forward); } private string GetPath(Transform child) { string text = ((Object)child).name; Transform parent = child.parent; while (((Object)parent).name != "Visual") { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } private void UpdateConfig() { Setup.writeYML(); } } public class Mountable_L : MonoBehaviour { private GameObject mountPoint; private Transform mountPointBase; private GameObject saddle; private Vector3 SaddleToMountPoint; private float flyStaminaDrain = 10f; public bool canfly = false; private Animator anim; public string Type; public static ManualLogSource logger; public void Awake() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_06d3: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_07f8: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_084c: Unknown result type (might be due to invalid IL or missing references) //IL_084e: Unknown result type (might be due to invalid IL or missing references) //IL_087c: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_088d: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_0897: Unknown result type (might be due to invalid IL or missing references) //IL_08a3: Unknown result type (might be due to invalid IL or missing references) //IL_08a9: Unknown result type (might be due to invalid IL or missing references) //IL_08ae: Unknown result type (might be due to invalid IL or missing references) //IL_08b3: Unknown result type (might be due to invalid IL or missing references) //IL_08bf: Unknown result type (might be due to invalid IL or missing references) //IL_0866: Unknown result type (might be due to invalid IL or missing references) //IL_0868: Unknown result type (might be due to invalid IL or missing references) //IL_0944: Unknown result type (might be due to invalid IL or missing references) //IL_0958: Unknown result type (might be due to invalid IL or missing references) //IL_095d: Unknown result type (might be due to invalid IL or missing references) //IL_098b: Unknown result type (might be due to invalid IL or missing references) //IL_099f: Unknown result type (might be due to invalid IL or missing references) //IL_09a4: Unknown result type (might be due to invalid IL or missing references) //IL_09c8: Unknown result type (might be due to invalid IL or missing references) //IL_09d8: Unknown result type (might be due to invalid IL or missing references) //IL_09dd: Unknown result type (might be due to invalid IL or missing references) //IL_09e2: Unknown result type (might be due to invalid IL or missing references) //IL_0a74: Unknown result type (might be due to invalid IL or missing references) //IL_0a8c: Unknown result type (might be due to invalid IL or missing references) //IL_0aa5: Unknown result type (might be due to invalid IL or missing references) //IL_0aaa: Unknown result type (might be due to invalid IL or missing references) //IL_0aaf: Unknown result type (might be due to invalid IL or missing references) //IL_0ac7: Unknown result type (might be due to invalid IL or missing references) //IL_0acc: Unknown result type (might be due to invalid IL or missing references) //IL_0ad1: Unknown result type (might be due to invalid IL or missing references) if (logger == null) { logger = Setup.logger; } Humanoid component = ((Component)this).gameObject.GetComponent<Humanoid>(); Transform val = ((Component)component).gameObject.transform.Find("Visual"); mountPoint = new GameObject("MountPoint"); mountPoint.transform.parent = val; mountPoint.transform.rotation = ((Component)this).transform.rotation; Tameable component2 = ((Component)this).GetComponent<Tameable>(); Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; Vector3 one = Vector3.one; Vector3 zero3 = Vector3.zero; if (!Setup.mountNameDict.ContainsKey(Type)) { return; } logger.LogInfo((object)("Setting up old \"" + Type + "\" for riding.")); string text = Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value; if (text.Contains("\\")) { logger.LogWarning((object)(Type + " Mount Path should use '/' rather than '\\', trying to replace")); text.Replace('\\', '/'); Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value = text; } if (text != "") { mountPointBase = val.Find(text); } zero = Setup.customMountPoints[Setup.mountNameDict[Type]].Value; zero2 = Setup.customSaddlePos[Setup.mountNameDict[Type]].Value; one = Setup.customSaddleScale[Setup.mountNameDict[Type]].Value; zero3 = Setup.customSaddleRot[Setup.mountNameDict[Type]].Value; if ((Object)(object)mountPointBase == (Object)null) { string[] array; if (!(text == "")) { mountPoint.transform.parent = val; string text2 = ""; array = text.Split(new char[1] { '/' }); string[] array2 = array; foreach (string text3 in array2) { if (!text2.Equals("")) { text2 += "/"; } if ((Object)(object)val.Find(text2 + text3) == (Object)null) { string text4 = Type + " Mount Path '" + text + "' is not correct. "; if (text2 != "") { text4 = text4 + "'" + text2 + "' appears to work. "; } text4 = text4 + text3 + " cannot be found in " + Type + " body. " + Type + " will not be rideable."; ((Component)component).GetComponent<Tameable>().m_saddleItem = null; logger.LogError((object)text4); return; } text2 += text3; } logger.LogError((object)("Unknown error in setting up saddle and riding for " + Type + ", it will not be rideable")); ((Component)component).GetComponent<Tameable>().m_saddleItem = null; return; } Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(); string[] array3 = new string[4] { "spine1", "tail2", "spine", "head" }; List<string> list = new List<string>(); array = array3; string[] array4 = array; foreach (string text5 in array4) { Transform[] array5 = componentsInChildren; Transform[] array6 = array5; foreach (Transform val2 in array6) { if (((Object)val2).name.ToLowerInvariant() == text5) { if ((Object)(object)mountPointBase == (Object)null) { mountPointBase = val2; text = GetPath(val2); } else { list.Add(GetPath(val2)); } break; } } } if ((Object)(object)mountPointBase == (Object)null) { array = array3; string[] array7 = array; foreach (string value in array7) { Transform[] array8 = componentsInChildren; Transform[] array9 = array8; foreach (Transform val3 in array9) { string text6 = ((Object)val3).name.ToLowerInvariant(); if (text6.StartsWith(value) || text6.EndsWith(value)) { if ((Object)(object)mountPointBase == (Object)null) { mountPointBase = val3; text = GetPath(val3); } else { list.Add(GetPath(val3)); } break; } } } } if (!((Object)(object)mountPointBase != (Object)null)) { logger.LogError((object)("Could not find potential Mount Path for " + Type + ". " + Type + " will not be rideable")); ((Component)component).GetComponent<Tameable>().m_saddleItem = null; return; } string text7 = ""; if (list.Count > 0) { text7 = "\nPossible Alternatives:"; foreach (string item in list) { text7 = text7 + "\n" + item; } } Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value = text; logger.LogMessage((object)("Found potential Mount Path for " + Type + ": " + text + text7)); } mountPoint.transform.parent = val; Transform transform = mountPoint.transform; transform.rotation *= Quaternion.Euler(zero3); saddle = Object.Instantiate<GameObject>(Setup.tieredSaddlePrefabs[0], val); Transform transform2 = saddle.transform; transform2.rotation *= Quaternion.Euler(zero3); saddle.GetComponent<Sadle>().m_maxStamina = Setup.customStamina[Setup.mountNameDict[Type]].Value; flyStaminaDrain = Setup.customMountFlyStamina[Setup.mountNameDict[Type]].Value; BaseAI baseAI = ((Character)component).GetBaseAI(); MonsterAI val4 = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null); if ((Object)(object)val4 != (Object)null && val4.m_avoidLand) { saddle.GetComponent<Sadle>().m_swimStaminaDrain = 0f; } if (flyStaminaDrain > 0f || ((Character)component).IsFlying()) { canfly = true; } Sadle component3 = saddle.GetComponent<Sadle>(); component3.m_hoverText = Type + " Saddle"; component3.m_attachPoint = mountPoint.transform; saddle.SetActive(false); component2.m_saddle = component3; ((Component)component3).transform.localPosition = zero2; ((Component)component3).transform.localScale = Vector3.Scale(one, Setup.legacyScale); if (Setup.adjustCustom.Value) { anim = ((Component)component).gameObject.GetComponentInChildren<Animator>(); if ((Object)(object)anim != (Object)null) { ((Behaviour)anim).enabled = false; } } if (zero3 != Vector3.zero) { ((Component)component3).GetComponentInChildren<Transform>().localRotation = Quaternion.Euler(zero3); } Transform transform3 = ((Component)component3).transform; transform3.position += ((Component)component3).transform.rotation * Setup.legacyOffset; zero += Setup.MountPointAdjustment.Value; mountPoint.transform.localPosition = zero; if ((Object)(object)component2.m_saddle != (Object)null) { component2.m_nview.Register("AddSaddle", (Action<long>)component2.RPC_AddSaddle); component2.m_nview.Register<bool>("SetSaddle", (Action<long, bool>)component2.RPC_SetSaddle); component2.SetSaddle(component2.HaveSaddle()); } mountPoint.transform.parent = mountPointBase; Transform transform4 = mountPoint.transform; transform4.localRotation *= Quaternion.Euler(180f, 180f, 180f); saddle.transform.parent = mountPointBase; Transform transform5 = saddle.transform; transform5.localRotation *= Quaternion.Euler(180f, 180f, 180f); SphereCollider component4 = saddle.GetComponent<SphereCollider>(); SaddleToMountPoint = mountPoint.transform.position - saddle.transform.position; if (!Setup.customMounts.ContainsKey(Type)) { Mount mount = new Mount(); int index = Setup.mountNameDict[Type]; mount.PrefabName = Type; mount.mountPath = text; mount.stamina = Setup.customStamina[index].Value; mount.saddleTier = Setup.customMountSaddleTiers[index].Value; mount.mountPoint = mountPoint.transform.localPosition; mount.saddlePos = saddle.transform.localPosition; mount.saddleScale = Vector3.Scale(Setup.customSaddleScale[index].Value, Setup.legacyScale); mount.saddleRotation = saddle.transform.localEulerAngles - Setup.rotationAdjust; mount.flyingStamina = Setup.customMountFlyStamina[index].Value; Setup.customMounts.Add(Type, mount); if (!Setup.AddFullMountToYaml.Contains(Type)) { Setup.AddFullMountToYaml.Add(Type); } replaceOldMount(Type); Setup.writeYML(); } } private static void replaceOldMount(string prefName) { GameObject prefab = PrefabManager.Instance.GetPrefab(prefName); Mountable_L mountable_L = default(Mountable_L); if (prefab.TryGetComponent<Mountable_L>(ref mountable_L)) { Object.DestroyImmediate((Object)(object)mountable_L); } Mountable mountable = default(Mountable); if (!prefab.TryGetComponent<Mountable>(ref mountable)) { mountable = prefab.AddComponent<Mountable>(); } mountable.Type = prefName; } private string GetPath(Transform child) { string text = ((Object)child).name; Transform parent = child.parent; while (((Object)parent).name != "Visual") { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } } public class MountUp { public enum AdjustMode { None, Saddle, Mount, Rotation } [HarmonyPatch(typeof(Tameable), "SetSaddle")] public static class InterceptSetSaddle { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { bool skipped = false; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldarg_0) { skipped = true; } if (skipped) { yield return instruction; } } } } public static GameObject keyDisplayPanel; public static Text EditModeTitle; public static Text commandDisplay; public static Text keyDisplay; public static string CommandStringPos = ""; public static string CommandStringRot = ""; public static string keyString = ""; public static float dampingPercent = 0.9f; public static float AdjustSpeed = 0.9f; public static Vector3 sumOffset = Vector3.zero; public static int countOffset = 0; public static Vector3 avgOffset = Vector3.zero; public static Vector3 lastPos = Vector3.zero; public static Vector3 speedMulti = Vector3.one; public static float max_dist = 2f; public static float lossyfactor = 0.25f; public static AdjustMode adjustMode; [HarmonyPostfix] [HarmonyPatch(typeof(LevelEffects), "Start")] private static void LevelEffectsStart_Patch(LevelEffects __instance) { if (Object.op_Implicit((Object)(object)__instance.m_baseEnableObject)) { Mountable component = __instance.m_baseEnableObject.GetComponent<Mountable>(); if (Object.op_Implicit((Object)(object)component)) { component.ResetMountPoint(); } } } [HarmonyPatch(typeof(Sadle), "Interact")] [HarmonyPrefix] private static void Sadle_Interact_Patch(Sadle __instance) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) Mountable mountable = default(Mountable); if (((Component)__instance.m_character).TryGetComponent<Mountable>(ref mountable)) { mountable.updateLocation(); } __instance.m_character.m_maxAirAltitude = ((Component)__instance).transform.position.y; __instance.m_character.m_groundContact = false; } [HarmonyPatch(typeof(ZNetScene), "Shutdown")] [HarmonyPostfix] private static void Postfix() { Debug.Log((object)"Reseting Mounts"); Setup.ResetAllMounts(); } [HarmonyPatch(typeof(LevelEffects), "SetupLevelVisualization")] [HarmonyPostfix] private static void LevelEffectsSetupLevelVisualization_Patch(LevelEffects __instance) { Mountable mountable = default(Mountable); if (Object.op_Implicit((Object)(object)__instance.m_character) && ((Component)__instance.m_character).gameObject.TryGetComponent<Mountable>(ref mountable)) { mountable.ResetMountPoint(); } } private static void displayKeybinds(bool active) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)keyDisplayPanel)) { if (GUIManager.Instance == null) { Debug.LogError((object)"GUIManager instance is null"); return; } if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { Debug.LogError((object)"GUIManager CustomGUI is null"); return; } SetCommandsStrings(); keyDisplayPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -300f), 400f, 500f, false); ((Behaviour)keyDisplayPanel.GetComponent<Image>()).enabled = false; GameObject val = GUIManager.Instance.CreateText(keyString.Substring(0, keyString.IndexOf('\n')), keyDisplayPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(187f, -265f), GUIManager.Instance.AveriaSerifBold, 20, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 500f, false); keyDisplay = val.GetComponent<Text>(); GameObject val2 = GUIManager.Instance.CreateText(CommandStringPos.Substring(0, CommandStringPos.IndexOf('\n')), keyDisplayPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-45f, -265f), GUIManager.Instance.AveriaSerifBold, 20, Color.white, true, Color.black, 300f, 500f, false); commandDisplay = val2.GetComponent<Text>(); commandDisplay.alignment = (TextAnchor)2; GameObject val3 = GUIManager.Instance.CreateText("Not Editing", keyDisplayPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(50f, 5f), GUIManager.Instance.AveriaSerifBold, 27, Color.red, true, Color.black, 400f, 40f, false); EditModeTitle = val3.GetComponent<Text>(); EditModeTitle.alignment = (TextAnchor)7; } keyDisplayPanel.SetActive(active); } public static string getKeybingsString() { //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_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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) string text = ""; string text2 = text; KeyboardShortcut value = Setup.adjustCustomModeSwitch.Value; text = text2 + string.Join("+", ((KeyboardShortcut)(ref value)).Modifiers); string text3 = text; value = Setup.adjustCustomModeSwitch.Value; KeyCode val = ((KeyboardShortcut)(ref value)).MainKey; text = text3 + "+" + ((object)(KeyCode)(ref val)).ToString() + "\n"; string[] obj = new string[5] { text, null, null, null, null }; val = (KeyCode)276; obj[1] = ((object)(KeyCode)(ref val)).ToString(); obj[2] = "/"; val = (KeyCode)275; obj[3] = ((object)(KeyCode)(ref val)).ToString(); obj[4] = "\n"; text = string.Concat(obj); string[] obj2 = new string[5] { text, null, null, null, null }; val = (KeyCode)273; obj2[1] = ((object)(KeyCode)(ref val)).ToString(); obj2[2] = "/"; val = (KeyCode)274; obj2[3] = ((object)(KeyCode)(ref val)).ToString(); obj2[4] = "\n"; text = string.Concat(obj2); string[] obj3 = new string[5] { text, null, null, null, null }; val = (KeyCode)280; obj3[1] = ((object)(KeyCode)(ref val)).ToString(); obj3[2] = "/"; val = (KeyCode)281; obj3[3] = ((object)(KeyCode)(ref val)).ToString(); obj3[4] = "\n"; text = string.Concat(obj3); string[] obj4 = new string[5] { text, null, null, null, null }; val = (KeyCode)306; obj4[1] = ((object)(KeyCode)(ref val)).ToString(); obj