Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BetterArchery Temporary Patch v1.9.7
BetterArchery.dll
Decompiled 2 years ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using Auga; using BepInEx; using BepInEx.Configuration; using Common; using HarmonyLib; using JetBrains.Annotations; using LitJson; using TMPro; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: Guid("04f6ef99-721d-41d7-86e2-59ced874c902")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyProduct("BetterArchery")] [assembly: AssemblyCompany("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("BetterArchery")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] namespace BetterArchery { public class Arrow { public float SpawnChance { get; set; } public string SpawnArrow { get; set; } } [BepInPlugin("ishid4.mods.betterarchery", "Better Archery", "1.9.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BetterArchery : BaseUnityPlugin { public enum ZoomState { Fixed, ZoomingIn, ZoomingOut } public static bool zoomSFX; public static Dictionary<string, Dictionary<string, AudioClip>> customSFXDict = new Dictionary<string, Dictionary<string, AudioClip>>(); public static bool speedReduction; public static bool isContainerOpen; public static float ZoomInTimer = 0f; public static float ZoomOutTimer; public static float ZoomOutDelayTimer = 0f; public static float __BaseFov; public static float __LastZoomFov; public static float __NewZoomFov = 0f; public static ZoomState __ZoomState; public const int QuiverUseSlotCount = 3; public static int QuiverRowIndex = 0; public static ConfigEntry<KeyboardShortcut> HoldingKeyCode; public static ConfigEntry<KeyboardShortcut>[] KeyCodes = new ConfigEntry<KeyboardShortcut>[3]; public static ConfigEntry<float>[] ArrowRetrieveChance = new ConfigEntry<float>[11]; public static ConfigEntry<string>[] ArrowRetrieveSpawnType = new ConfigEntry<string>[11]; public static List<Arrow> ArrowRetrieves = new List<Arrow>(); public static ConfigEntry<float> ArrowDisappearTime; public static ConfigEntry<bool> ArrowDisappearOnHit; public static ConfigEntry<bool> ArrowRetrieveOldVersion; public static ConfigEntry<Vector2> InventoryQuiverSlotLocation; public static ConfigEntry<Vector2> InventoryQuiverSlotLocationWithContainer; public static ConfigEntry<bool> QuiverHudEnabled; public static ConfigEntry<float> ArrowVelocity; public static ConfigEntry<float> ArrowGravity; public static ConfigEntry<float> ArrowAccuracy; public static ConfigEntry<Vector3> ArrowAimDir; public static ConfigEntry<bool> configQuiverEnabled; public static ConfigEntry<bool> configArrowImprovementsEnabled; public static ConfigEntry<bool> configRetrievableArrowsEnabled; public static ConfigEntry<bool> configBowZoomEnabled; public static ConfigEntry<KeyboardShortcut> BowDrawCancelKey; public static ConfigEntry<float> BowZoomFactor; public static ConfigEntry<bool> AutomaticBowZoom; public static ConfigEntry<KeyboardShortcut> BowZoomKey; public static ConfigEntry<float> BowZoomConstantTime; public static ConfigEntry<bool> BowZoomSFXEnabled; public static ConfigEntry<float> StayInZoomTime; public static ConfigEntry<bool> IsCrosshairVisible; public static ConfigEntry<bool> IsBowCrosshairVisible; public static ConfigEntry<bool> ShowSneakDamage; public static ConfigEntry<bool> BowDrawMovementSpeedReductionEnabled; public static ConfigEntry<int> _DebugLevel; public static RecipesConfig Recipes; public static ConfigEntry<bool> WoodenArrowEverywhereEnabled; public static readonly Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>(); public static ConfigEntry<int> nexusID; public static AudioSource playerAudioSource; private Harmony _harmony; public static BetterArchery _instance; public static bool HasAuga { get; private set; } public static void Log(string str = "", int warningType = 2) { if (_DebugLevel.Value == 0) { return; } if (warningType == 0) { Debug.LogError((object)("[" + typeof(BetterArchery).Namespace + "]: " + str)); } if (_DebugLevel.Value > 1) { if (warningType == 1) { Debug.LogWarning((object)("[" + typeof(BetterArchery).Namespace + "]: " + str)); } if (_DebugLevel.Value > 2 && warningType == 2) { Debug.Log((object)("[" + typeof(BetterArchery).Namespace + "]: " + str)); } } } private void Awake() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) _instance = this; configQuiverEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Quiver", "Enable Quiver", true, "Enable the quiver. Don't change this value while in the game. If you disable this while arrows are in the quiver, you will LOSE ALL OF THEM!"); InventoryQuiverSlotLocation = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Quiver", "Change location of inventory quiver slot", new Vector2(3f, -25f), "Change quiver slot inventory location. For 'More Slots' you can use this location, 'x:3.0, y:-167.0'."); InventoryQuiverSlotLocationWithContainer = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Quiver", "Change location of inventory quiver slot when a chest opened", new Vector2(3f, -425f), "Change quiver slot inventory location when a chest opened."); QuiverHudEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Quiver", "Enable Quiver Hud", true, "Enable the quiver's hotbar on the screen/hud. This doesn't affect inventory."); HoldingKeyCode = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Quiver", "Quiver slot hotkey holding key", new KeyboardShortcut((KeyCode)308, Array.Empty<KeyCode>()), "Change holding key. For the inputs: https://docs.unity3d.com/ScriptReference/KeyCode.html"); KeyCodes[0] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Quiver", "Quiver slot hotkey 1", new KeyboardShortcut((KeyCode)49, Array.Empty<KeyCode>()), "Hotkey for Quiver Slot 1. For the inputs: https://docs.unity3d.com/ScriptReference/KeyCode.html"); KeyCodes[1] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Quiver", "Quiver slot hotkey 2", new KeyboardShortcut((KeyCode)50, Array.Empty<KeyCode>()), "Hotkey for Quiver Slot 2. For the inputs: https://docs.unity3d.com/ScriptReference/KeyCode.html"); KeyCodes[2] = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Quiver", "Quiver slot hotkey 3", new KeyboardShortcut((KeyCode)51, Array.Empty<KeyCode>()), "Hotkey for Quiver Slot 3. For the inputs: https://docs.unity3d.com/ScriptReference/KeyCode.html"); configArrowImprovementsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Arrow Improvements", "Enable Arrow Improvements", true, "Arrow improvements including aim problems fixes, gravity changes."); ArrowVelocity = ((BaseUnityPlugin)this).Config.Bind<float>("Arrow Improvements", "Set Arrow Velocity", 70f, "Change the arrow's velocity. Vanilla is '60'."); ArrowGravity = ((BaseUnityPlugin)this).Config.Bind<float>("Arrow Improvements", "Set Arrow Gravity", 15f, "Change the arrow's gravity. Vanilla is '5'."); ArrowAccuracy = ((BaseUnityPlugin)this).Config.Bind<float>("Arrow Improvements", "Set Arrow Accuracy", 0f, "Change the arrow's accuracy. Vanilla is '-1'."); ArrowAimDir = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Arrow Improvements", "Set Aim Direction", new Vector3(0f, 0.05f, 0f), "Change the aim direction. Vanilla is 'x:0.0, y:0.0, z: 0.0'."); configBowZoomEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Bow Zoom", "Enable Bow Zoom", true, "Enable the zooming with bow."); AutomaticBowZoom = ((BaseUnityPlugin)this).Config.Bind<bool>("Bow Zoom", "Automatic Bow Zoom", false, "Zoom while drawing bow automatically."); BowZoomSFXEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Bow Zoom", "Enable Bow Zoom SFX", true, "Sound effects for zoom-in and zoom-out."); BowZoomFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Bow Zoom", "Zoom Factor", 2f, "Max zoom."); BowZoomConstantTime = ((BaseUnityPlugin)this).Config.Bind<float>("Bow Zoom", "Bow Zoom Constant Time", -1f, "Change this value to '-1' if you don't want constant time while zooming. '1' is recommended."); BowZoomKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Bow Zoom", "Bow Zoom Hotkey", new KeyboardShortcut((KeyCode)324, Array.Empty<KeyCode>()), "Mouse0: Left Click, Mouse1: Right Click, Mouse2: Middle Click. For the other inputs: https://docs.unity3d.com/ScriptReference/KeyCode.html"); BowDrawCancelKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Bow Zoom", "Bow Draw Cancel Hotkey", new KeyboardShortcut((KeyCode)101, Array.Empty<KeyCode>()), "Mouse0: Left Click, Mouse1: Right Click, Mouse2: Middle Click. For the other inputs: https://docs.unity3d.com/ScriptReference/KeyCode.html"); StayInZoomTime = ((BaseUnityPlugin)this).Config.Bind<float>("Bow Zoom", "Stay In-Zoom Time", 2f, "Set the max time of staying on zoom while holding RMB after releasing an arrow."); IsCrosshairVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Crosshair", true, "You can hide your crosshair."); IsBowCrosshairVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Bow Crosshair", true, "You can hide your bow crosshair, circle one."); ShowSneakDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Sneak Damage Showing", true, "Show sneak damage at top left."); BowDrawMovementSpeedReductionEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Bow Draw Movement Speed Reduction", true, "Set walk speed while drawing bow."); WoodenArrowEverywhereEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Crafting Wooden Arrow Everywhere", true, "Enable to crafting wooden arrows without a crafting table."); configRetrievableArrowsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Retrievable Arrows", "Enable Retrievable Arrows", true, "Enable the retrievable arrows."); ArrowDisappearTime = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "Arrow Disappear Time", 60f, "Set arrow's disappear countdown time."); ArrowDisappearOnHit = ((BaseUnityPlugin)this).Config.Bind<bool>("Retrievable Arrows", "Arrow Disappear On Hit", false, "Make arrows disappear when they are not retrievable."); ArrowRetrieveOldVersion = ((BaseUnityPlugin)this).Config.Bind<bool>("Retrievable Arrows", "Enable Old Retrievable Version", false, "Instantly arrow drops to the ground on hit if retrievable. Enabling this will ignore 'Arrow Disappear On Hit' and 'Arrow Disappear Time' settings."); ArrowRetrieveChance[0] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Wooden Arrow", 0.2f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[1] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Flint Arrow", 0.3f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[2] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Bronze Arrow", 0.5f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[3] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Iron Arrow", 0.7f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[4] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Obsidian Arrow", 0.7f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[5] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Needle Arrow", 0.1f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[6] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Fire Arrow", 0f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[7] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Poison Arrow", 0.7f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[8] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Silver Arrow", 0.5f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[9] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Frost Arrow", 0.7f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveChance[10] = ((BaseUnityPlugin)this).Config.Bind<float>("Retrievable Arrows", "ArrowRetrieveChance for Carapace Arrow", 0.7f, "Example: 0.9 for 90% chance to retrieve."); ArrowRetrieveSpawnType[0] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Wooden Arrow", "ArrowWood", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[1] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Flint Arrow", "ArrowFlint", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[2] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Bronze Arrow", "ArrowBronze", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[3] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Iron Arrow", "ArrowIron", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[4] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Obsidian Arrow", "ArrowObsidian", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[5] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Needle Arrow", "ArrowNeedle", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[6] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Fire Arrow", "ArrowFire", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[7] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Poison Arrow", "ArrowObsidian", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[8] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Silver Arrow", "ArrowSilver", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[9] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Frost Arrow", "ArrowObsidian", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); ArrowRetrieveSpawnType[10] = ((BaseUnityPlugin)this).Config.Bind<string>("Retrievable Arrows", "ArrowRetrieveSpawnType for Carapace Arrow", "ArrowCarapace", "https://valheim.fandom.com/wiki/Category:Arrows use internal ids."); for (int i = 0; i < ArrowRetrieveSpawnType.Length; i++) { ArrowRetrieves.Add(new Arrow { SpawnChance = ArrowRetrieveChance[i].Value, SpawnArrow = ArrowRetrieveSpawnType[i].Value }); } nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("Other", "NexusID", 348, "Nexus mod ID for updates."); _DebugLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Other", "Set Debug Log Level", 1, "0: Nothing, 1: Only Errors, 2: Errors and Warnings, 3: Everyting"); Recipes = LoadJsonFile<RecipesConfig>("BetterArcheryRecipes.json"); if (configQuiverEnabled.Value) { AssetBundle val = LoadAssetBundle("quiverassets"); if (Recipes != null && (Object)(object)val != (Object)null) { foreach (RecipeConfig recipe in Recipes.recipes) { if (val.Contains(recipe.item)) { GameObject value = val.LoadAsset<GameObject>(recipe.item); Prefabs.Add(recipe.item, value); } } } if (val != null) { val.Unload(false); } } _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); HasAuga = API.IsLoaded(); } public void Start() { HasAuga = API.IsLoaded(); if (HasAuga) { Log("Auga Loaded."); } } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } foreach (GameObject value in Prefabs.Values) { Object.Destroy((Object)(object)value); } Prefabs.Clear(); } private void Update() { if (!configQuiverEnabled.Value) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && ((Character)localPlayer).TakeInput()) { for (int i = 0; i < 3; i++) { CheckQuiverUseInput(localPlayer, i); } } } public static string GetBindingLabel(int index) { //IL_000c: 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) index = Mathf.Clamp(index, 0, 2); KeyCode bindingKeycode = GetBindingKeycode(index); return ((object)(KeyCode)(ref bindingKeycode)).ToString().Contains("Alpha") ? ((object)(KeyCode)(ref bindingKeycode)).ToString().Replace("Alpha", "") : ((object)(KeyCode)(ref bindingKeycode)).ToString().ToUpperInvariant(); } public static KeyCode GetBindingKeycode(int index) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) index = Mathf.Clamp(index, 0, 2); KeyboardShortcut value = KeyCodes[index].Value; return ((KeyboardShortcut)(ref value)).MainKey; } public static int GetBonusInventoryRowIndex() { return ((Object)(object)Player.m_localPlayer != (Object)null && QuiverRowIndex != 0) ? QuiverRowIndex : 0; } public static void CheckQuiverUseInput(Player player, int index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) KeyCode bindingKeycode = GetBindingKeycode(index); KeyboardShortcut value = HoldingKeyCode.Value; KeyboardShortcut value2; int num; if (!string.IsNullOrEmpty(((KeyboardShortcut)(ref value)).Serialize())) { value2 = HoldingKeyCode.Value; num = ((((KeyboardShortcut)(ref value2)).Serialize() != "None") ? 1 : 0); } else { num = 0; } bool flag; if (num != 0) { value2 = HoldingKeyCode.Value; flag = Input.GetKey(((KeyboardShortcut)(ref value2)).MainKey) && Input.GetKeyDown(bindingKeycode); } else { flag = Input.GetKeyDown(bindingKeycode); } if (flag) { int bonusInventoryRowIndex = GetBonusInventoryRowIndex(); ItemData itemAt = ((Humanoid)player).GetInventory().GetItemAt(index, bonusInventoryRowIndex); if (itemAt != null) { ((Humanoid)player).UseItem((Inventory)null, itemAt, false); } } } public static bool IsQuiverSlot(Vector2i pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return IsQuiverSlot(pos.x, pos.y); } public static bool IsQuiverSlot(int x, int y) { int bonusInventoryRowIndex = GetBonusInventoryRowIndex(); return y == bonusInventoryRowIndex && x >= 0 && x < 3; } public static Vector2i GetQuiverSlotPosition(int index) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) int bonusInventoryRowIndex = GetBonusInventoryRowIndex(); return new Vector2i(index, bonusInventoryRowIndex); } public static bool IsQuiverEquipped() { return !((Object)(object)Player.m_localPlayer == (Object)null) && CustomSlotCreator.IsSlotOccupied((Humanoid)(object)Player.m_localPlayer, "quiver"); } private static T LoadJsonFile<T>(string filename) where T : class { string assetPath = GetAssetPath(filename); return (!string.IsNullOrEmpty(assetPath)) ? JsonMapper.ToObject<T>(File.ReadAllText(assetPath)) : null; } public static AssetBundle LoadAssetBundle(string filename) { Assembly callingAssembly = Assembly.GetCallingAssembly(); AssetBundle result = AssetBundle.LoadFromStream(callingAssembly.GetManifestResourceStream(callingAssembly.GetName().Name + "." + filename)); Log("Loaded AssetBundle (" + filename + ").", 3); Log(callingAssembly.GetName().Name); return result; } public static string GetAssetPath(string assetName, bool isDirectory = false) { string text = Path.Combine(Paths.PluginPath, "BetterArchery", assetName); if (isDirectory) { if (!Directory.Exists(text)) { text = Path.Combine(Path.GetDirectoryName(typeof(BetterArchery).Assembly.Location), assetName); if (!Directory.Exists(text)) { Log("Could not find directory (" + assetName + ").", 1); return null; } } return text; } if (!File.Exists(text)) { text = Path.Combine(Path.GetDirectoryName(typeof(BetterArchery).Assembly.Location), assetName); if (!File.Exists(text)) { Log("Could not find asset (" + assetName + ").", 1); return null; } } return text; } public static void TryCreateCustomSlot(ZNetScene zNetScene) { if (!((Object)(object)zNetScene == (Object)null) && configQuiverEnabled.Value) { CustomSlotCreator.ApplyCustomSlotItem(zNetScene.GetPrefab("LeatherQuiver"), "quiver"); } } public static void TryCreateCustomSFX() { if (!configBowZoomEnabled.Value || !BowZoomSFXEnabled.Value) { return; } string assetPath = GetAssetPath("SFX", isDirectory: true); if (string.IsNullOrEmpty(assetPath)) { Log("SFX folder not found."); return; } Log("path: " + assetPath); string[] directories = Directory.GetDirectories(assetPath); foreach (string path in directories) { Log("Checking folder " + Path.GetFileName(path)); customSFXDict[Path.GetFileName(path)] = new Dictionary<string, AudioClip>(); string[] files = Directory.GetFiles(path); foreach (string path2 in files) { if (Path.GetExtension(path2).ToLower().Equals(".wav")) { Log("Checking file " + Path.GetFileName(path2)); ((MonoBehaviour)_instance).StartCoroutine(LoadSFXCoroutine(path2, customSFXDict[Path.GetFileName(path)])); } } } } public static void PlayCustomSFX(string name, bool checkIfPlaying = true) { if ((Object)(object)playerAudioSource == (Object)null || !BowZoomSFXEnabled.Value) { return; } ZSFX component = ((Component)playerAudioSource).GetComponent<ZSFX>(); if (!(component.IsPlaying() && checkIfPlaying)) { if (customSFXDict.ContainsKey(name)) { component.m_audioClips = customSFXDict[name].Values.ToArray(); component.Play(); } else { Log("SFX not found.", 0); } } } public static IEnumerator LoadSFXCoroutine(string path, Dictionary<string, AudioClip> dict) { path = "file:///" + path; UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20); bool flag; try { yield return www.SendWebRequest(); if (www == null) { Log("ww error.", 0); flag = false; } else { DownloadHandlerAudioClip dh = (DownloadHandlerAudioClip)www.downloadHandler; if (dh == null) { goto IL_018b; } AudioClip ac = dh.audioClip; if (!((Object)(object)ac != (Object)null)) { goto IL_018b; } ((Object)ac).name = Path.GetFileNameWithoutExtension(path); if (!dict.ContainsKey(((Object)ac).name)) { dict[((Object)ac).name] = ac; } Log("Added " + ((Object)ac).name + " SFX."); flag = false; } goto end_IL_005f; IL_018b: Log("Error while adding custom SFX.", 0); flag = false; end_IL_005f:; } finally { ((IDisposable)www)?.Dispose(); } yield return flag; } public static void TryRegisterPrefabs(ZNetScene zNetScene) { if ((Object)(object)zNetScene == (Object)null) { return; } foreach (GameObject value in Prefabs.Values) { if (!configQuiverEnabled.Value) { Log(((Object)value).name); if (((Object)value).name.Contains("Quiver")) { Debug.Log((object)("[PrefabCreator] " + ((Object)value).name + " prefab skipped.")); continue; } } if (!zNetScene.m_prefabs.Contains(value)) { zNetScene.m_prefabs.Add(value); } } } public static bool IsObjectDBReady() { return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } public static void TryRegisterItems() { if (!IsObjectDBReady()) { return; } foreach (GameObject value in Prefabs.Values) { ItemDrop component = value.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { if (!configQuiverEnabled.Value && ((Object)component.m_itemData.m_dropPrefab).name.Contains("Quiver")) { Debug.Log((object)("[PrefabCreator] Skipped prefab: " + ((Object)component.m_itemData.m_dropPrefab).name)); } else if ((Object)(object)ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(((Object)value).name)) == (Object)null) { component.m_itemData.m_dropPrefab = value; ObjectDB.instance.m_items.Add(value); } } } ObjectDB.instance.UpdateItemHashes(); } public static void TryRegisterRecipes() { if (!IsObjectDBReady()) { return; } PrefabCreator.Reset(); foreach (RecipeConfig recipe in Recipes.recipes) { if (!configQuiverEnabled.Value && recipe.item.Contains("Quiver")) { Debug.Log((object)("[PrefabCreator] Skipped recipe: " + recipe.name)); } else if (!WoodenArrowEverywhereEnabled.Value && recipe.name == "Recipe_ArrowWoodAnywhere") { Debug.Log((object)("[PrefabCreator] Skipped recipe: " + recipe.name)); } else { PrefabCreator.AddNewRecipe(recipe.name, recipe.item, recipe); } } } } [HarmonyPatch] public class Patches { [HarmonyPostfix] [HarmonyPatch(typeof(ItemData), "IsEquipable")] private static void IsEquipablePostfix(ref bool __result, ref ItemData __instance) { __result = __result || CustomSlotCreator.IsCustomSlotItem(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(Humanoid), "Awake")] private static void HumanoidEntryPostfix(ref Humanoid __instance) { CustomSlotCreator.customSlotItemData[__instance] = new Dictionary<string, ItemData>(); } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Load")] private static void InventoryLoadPostfix(ref Player __instance) { foreach (ItemData equippedItem in ((Humanoid)__instance).m_inventory.GetEquippedItems()) { if (CustomSlotCreator.IsCustomSlotItem(equippedItem)) { string customSlotName = CustomSlotCreator.GetCustomSlotName(equippedItem); CustomSlotCreator.SetSlotItem((Humanoid)(object)__instance, customSlotName, equippedItem); } } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] [HarmonyPostfix] private static void EquipItemPostfix(ref bool __result, ref Humanoid __instance, ItemData item, bool triggerEquipEffects = true) { if (CustomSlotCreator.IsCustomSlotItem(item)) { string customSlotName = CustomSlotCreator.GetCustomSlotName(item); if (CustomSlotCreator.IsSlotOccupied(__instance, customSlotName)) { __instance.UnequipItem(CustomSlotCreator.GetSlotItem(__instance, customSlotName), triggerEquipEffects); } CustomSlotCreator.SetSlotItem(__instance, customSlotName, item); if (__instance.IsItemEquiped(item)) { item.m_equipped = true; } __instance.SetupEquipment(); if (triggerEquipEffects) { __instance.TriggerEquipEffect(item); } __result = true; } } [HarmonyPostfix] [HarmonyPatch(typeof(Humanoid), "UnequipItem")] private static void UnequipItemPostfix(ref Humanoid __instance, ItemData item, bool triggerEquipEffects = true) { if (CustomSlotCreator.IsCustomSlotItem(item)) { string customSlotName = CustomSlotCreator.GetCustomSlotName(item); if (item == CustomSlotCreator.GetSlotItem(__instance, customSlotName)) { CustomSlotCreator.SetSlotItem(__instance, customSlotName, null); } __instance.UpdateEquipmentStatusEffects(); } } [HarmonyPatch(typeof(Humanoid), "IsItemEquiped")] [HarmonyPostfix] private static void IsItemEquipedPostfix(ref bool __result, ref Humanoid __instance, ItemData item) { if (CustomSlotCreator.IsCustomSlotItem(item)) { string customSlotName = CustomSlotCreator.GetCustomSlotName(item); bool flag = CustomSlotCreator.DoesSlotExist(__instance, customSlotName) && CustomSlotCreator.GetSlotItem(__instance, customSlotName) == item; __result |= flag; } } [HarmonyPatch(typeof(Humanoid), "GetEquipmentWeight")] [HarmonyPostfix] private static void GetEquipmentWeightPostfix(ref float __result, ref Humanoid __instance) { foreach (string key in CustomSlotCreator.customSlotItemData[__instance].Keys) { if (CustomSlotCreator.IsSlotOccupied(__instance, key)) { __result += CustomSlotCreator.GetSlotItem(__instance, key).m_shared.m_weight; } } } [HarmonyPatch(typeof(Humanoid), "UnequipAllItems")] [HarmonyPostfix] private static void UnequipAllItemsPostfix(ref Humanoid __instance) { foreach (string item in CustomSlotCreator.customSlotItemData[__instance].Keys.ToList()) { if (CustomSlotCreator.IsSlotOccupied(__instance, item)) { __instance.UnequipItem(CustomSlotCreator.GetSlotItem(__instance, item), false); } } } [HarmonyPatch(typeof(Humanoid), "GetSetCount")] [HarmonyPostfix] private static void GetSetCountPostfix(ref int __result, ref Humanoid __instance, string setName) { foreach (string item in CustomSlotCreator.customSlotItemData[__instance].Keys.ToList()) { if (CustomSlotCreator.IsSlotOccupied(__instance, item) && CustomSlotCreator.GetSlotItem(__instance, item).m_shared.m_setName == setName) { __result++; } } } public static HashSet<StatusEffect> GetStatusEffectsFromCustomSlotItems(Humanoid __instance) { HashSet<StatusEffect> hashSet = new HashSet<StatusEffect>(); foreach (string key in CustomSlotCreator.customSlotItemData[__instance].Keys) { if (CustomSlotCreator.IsSlotOccupied(__instance, key)) { if (Object.op_Implicit((Object)(object)CustomSlotCreator.GetSlotItem(__instance, key).m_shared.m_equipStatusEffect)) { StatusEffect equipStatusEffect = CustomSlotCreator.GetSlotItem(__instance, key).m_shared.m_equipStatusEffect; hashSet.Add(equipStatusEffect); } if (__instance.HaveSetEffect(CustomSlotCreator.GetSlotItem(__instance, key))) { StatusEffect setStatusEffect = CustomSlotCreator.GetSlotItem(__instance, key).m_shared.m_setStatusEffect; hashSet.Add(setStatusEffect); } } } return hashSet; } } [HarmonyPatch(typeof(InventoryGrid), "OnLeftClick")] public static class InventoryGrid_OnLeftClick_Patch { public static bool Prefix(InventoryGrid __instance, UIInputHandler clickHandler) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!BetterArchery.configQuiverEnabled.Value) { return true; } GameObject gameObject = ((Component)clickHandler).gameObject; Vector2i buttonPos = __instance.GetButtonPos(gameObject); ItemData itemAt = __instance.m_inventory.GetItemAt(buttonPos.x, buttonPos.y); if ((!Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305)) || itemAt == null || !itemAt.m_equipped || !((Object)itemAt.m_dropPrefab).name.Contains("Quiver")) { return true; } MessageHud.instance.ShowMessage((MessageType)2, "You can't drop the quiver while equipped.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui", new Type[] { typeof(Player), typeof(ItemData) })] public static class InventoryGrid_UpdateGui_Patch { public static Vector2 customLocation; private static void Postfix(InventoryGrid __instance, Player player, ItemData dragItem, List<Element> ___m_elements) { if (((Object)__instance).name != "PlayerGrid" || !BetterArchery.configQuiverEnabled.Value) { return; } if (__instance.GetInventory().GetHeight() > 5) { if (GetElement(___m_elements, 7, __instance.GetInventory().GetHeight() - 1).m_go.activeSelf) { for (int i = __instance.GetInventory().GetHeight() - 2; i < __instance.GetInventory().GetHeight(); i++) { for (int j = 0; j < 8; j++) { GetElement(___m_elements, j, i).m_go.SetActive(false); } } } } else if (GetElement(___m_elements, 7, __instance.GetInventory().GetHeight() - 1).m_go.activeSelf) { for (int k = __instance.GetInventory().GetHeight() - 1; k < __instance.GetInventory().GetHeight(); k++) { for (int l = 0; l < 8; l++) { GetElement(___m_elements, l, k).m_go.SetActive(false); } } } if (BetterArchery.IsQuiverEquipped()) { CreateQuiverSlots(__instance, ___m_elements); } else { RemoveQuiverSlots(__instance, ___m_elements); } } public static void CreateQuiverSlots(InventoryGrid __instance, List<Element> ___m_elements) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (BetterArchery.isContainerOpen ? BetterArchery.InventoryQuiverSlotLocationWithContainer.Value : BetterArchery.InventoryQuiverSlotLocation.Value); if (Object.op_Implicit((Object)(object)((Component)__instance).transform.parent.Find("QuiverSlotBkg")) && customLocation == val) { return; } int bonusInventoryRowIndex = BetterArchery.GetBonusInventoryRowIndex(); customLocation = (BetterArchery.isContainerOpen ? BetterArchery.InventoryQuiverSlotLocationWithContainer.Value : BetterArchery.InventoryQuiverSlotLocation.Value); KeyCode mainKey; if (BetterArchery.HasAuga) { Vector2 val4 = default(Vector2); for (int i = 0; i < 3; i++) { int num = i; Element element = GetElement(___m_elements, num, bonusInventoryRowIndex); element.m_go.SetActive(true); TMP_Text component = ((Component)element.m_go.transform.Find("binding")).GetComponent<TMP_Text>(); ((Behaviour)component).enabled = true; component.overflowMode = (TextOverflowModes)0; component.fontSize = 11f; component.autoSizeTextContainer = true; component.rectTransform.anchoredPosition = new Vector2(1f, 14f); KeyboardShortcut value = BetterArchery.HoldingKeyCode.Value; int num2; if (!string.IsNullOrEmpty(((KeyboardShortcut)(ref value)).Serialize())) { value = BetterArchery.HoldingKeyCode.Value; num2 = ((((KeyboardShortcut)(ref value)).Serialize() == "None") ? 1 : 0); } else { num2 = 1; } if (num2 != 0) { component.text = BetterArchery.GetBindingLabel(i); } else { TMP_Text val2 = component; value = BetterArchery.HoldingKeyCode.Value; mainKey = ((KeyboardShortcut)(ref value)).MainKey; string text = ((object)(KeyCode)(ref mainKey)).ToString() + " + " + BetterArchery.GetBindingLabel(i); val2.text = text; } Vector2 val3 = customLocation; ((Vector2)(ref val4))..ctor((float)num * __instance.m_elementSpace, (float)(4.0 * (0.0 - (double)__instance.m_elementSpace) + 30.0)); Transform transform = element.m_go.transform; ((RectTransform)((transform is RectTransform) ? transform : null)).anchoredPosition = val3 + val4; } RectTransform orCreateBackground = GetOrCreateBackground(__instance, "QuiverSlotBkg"); orCreateBackground.anchoredPosition = new Vector2(customLocation.x - 174f, customLocation.y - 235f); orCreateBackground.SetSizeWithCurrentAnchors((Axis)0, 235f); orCreateBackground.SetSizeWithCurrentAnchors((Axis)1, 90f); ((Transform)orCreateBackground).localScale = new Vector3(1f, 1f, 1f); return; } Vector2 val7 = default(Vector2); for (int j = 0; j < 3; j++) { int num3 = j; Element element2 = GetElement(___m_elements, num3, bonusInventoryRowIndex); element2.m_go.SetActive(true); TMP_Text component2 = ((Component)element2.m_go.transform.Find("binding")).GetComponent<TMP_Text>(); ((Behaviour)component2).enabled = true; component2.overflowMode = (TextOverflowModes)0; component2.horizontalAlignment = (HorizontalAlignmentOptions)2; component2.fontSize = 11f; component2.autoSizeTextContainer = true; component2.rectTransform.anchoredPosition = new Vector2(28f, -7f); KeyboardShortcut value2 = BetterArchery.HoldingKeyCode.Value; int num4; if (!string.IsNullOrEmpty(((KeyboardShortcut)(ref value2)).Serialize())) { value2 = BetterArchery.HoldingKeyCode.Value; num4 = ((((KeyboardShortcut)(ref value2)).Serialize() == "None") ? 1 : 0); } else { num4 = 1; } if (num4 != 0) { component2.text = BetterArchery.GetBindingLabel(j); } else { TMP_Text val5 = component2; value2 = BetterArchery.HoldingKeyCode.Value; mainKey = ((KeyboardShortcut)(ref value2)).MainKey; string text2 = ((object)(KeyCode)(ref mainKey)).ToString() + " + " + BetterArchery.GetBindingLabel(j); val5.text = text2; } Vector2 val6 = customLocation; ((Vector2)(ref val7))..ctor((float)num3 * __instance.m_elementSpace, (float)(4.0 * (0.0 - (double)__instance.m_elementSpace))); Transform transform2 = element2.m_go.transform; ((RectTransform)((transform2 is RectTransform) ? transform2 : null)).anchoredPosition = val6 + val7; } RectTransform orCreateBackground2 = GetOrCreateBackground(__instance, "QuiverSlotBkg"); float num5 = 3f - customLocation.x; float num6 = -25f - customLocation.y; orCreateBackground2.anchoredPosition = new Vector2((float)(0.0 - (double)num5 - 176.0), (float)(0.0 - (double)num6 - 200.0)); orCreateBackground2.SetSizeWithCurrentAnchors((Axis)0, 235f); orCreateBackground2.SetSizeWithCurrentAnchors((Axis)1, 90f); ((Transform)orCreateBackground2).localScale = new Vector3(1f, 1f, 1f); } public static void RemoveQuiverSlots(InventoryGrid __instance, List<Element> ___m_elements) { int bonusInventoryRowIndex = BetterArchery.GetBonusInventoryRowIndex(); for (int i = 0; i < 3; i++) { int x = i; GetElement(___m_elements, x, bonusInventoryRowIndex).m_go.SetActive(false); } Transform val = ((Component)__instance).transform.parent.Find("QuiverSlotBkg"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } private static RectTransform GetOrCreateBackground(InventoryGrid __instance, string name) { //IL_0060: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //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) Transform val = ((Component)__instance).transform.parent.Find(name); if ((Object)(object)val != (Object)null) { return (RectTransform)(object)((val is RectTransform) ? val : null); } if (BetterArchery.HasAuga) { BetterArchery.Log("GetOrCreateBackground: Auga is Active!"); GameObject val2 = API.Panel_Create(((Component)((Component)__instance).transform.parent).transform, new Vector2(10f, 10f), name, withCornerDecoration: true); Transform val3 = ((Component)__instance).transform.Find("Main"); ((Behaviour)((Component)val3).GetComponent<RectMask2D>()).enabled = false; ((Behaviour)((Component)((Component)val3).transform.Find("Grid")).GetComponent<GridLayoutGroup>()).enabled = false; if ((double)val3.localPosition.y > -40.0) { val3.localPosition = Vector2.op_Implicit(new Vector2(val3.localPosition.x, -64f)); } val2.transform.SetSiblingIndex(((Component)val3).transform.GetSiblingIndex() + 1); Transform transform = val2.transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } GameObject gameObject = ((Component)((Component)__instance).transform.parent.Find("Bkg")).gameObject; GameObject val4 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent); ((Object)val4).name = name; val4.transform.SetSiblingIndex(gameObject.transform.GetSiblingIndex() + 1); Transform transform2 = val4.transform; return (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); } private static Element GetElement(List<Element> elements, int x, int y) { int width = ((Humanoid)Player.m_localPlayer).GetInventory().GetWidth(); return elements[y * width + x]; } } [HarmonyPatch(typeof(InventoryGui), "OnSelectedItem", new Type[] { typeof(InventoryGrid), typeof(ItemData), typeof(Vector2i), typeof(Modifier) })] public static class InventoryGui_OnSelectedItem_Patch { public static bool Prefix(InventoryGui __instance, InventoryGrid grid, ItemData item, Vector2i pos, Modifier mod, GameObject ___m_dragGo, ItemData ___m_dragItem) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Invalid comparison between Unknown and I4 //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Invalid comparison between Unknown and I4 //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (!BetterArchery.configQuiverEnabled.Value) { return true; } BetterArchery.isContainerOpen = __instance.IsContainerOpen(); if (grid.m_inventory.m_name.Equals("Inventory") && BetterArchery.IsQuiverSlot(pos)) { if (___m_dragItem != null && (int)___m_dragItem.m_shared.m_itemType == 9) { return true; } if (___m_dragItem != null && (int)___m_dragItem.m_shared.m_itemType != 9) { MessageHud.instance.ShowMessage((MessageType)2, "You can not put this inside of the quiver.", 0, (Sprite)null); return false; } } if (Object.op_Implicit((Object)(object)__instance.m_dragGo)) { if (item != null && item.m_equipped && __instance.m_dragInventory != grid.GetInventory()) { MessageHud.instance.ShowMessage((MessageType)2, "Unequip the item.", 0, (Sprite)null); return false; } if (item != null && (int)___m_dragItem.m_shared.m_itemType == 9 && BetterArchery.IsQuiverSlot(___m_dragItem.m_gridPos)) { BetterArchery.Log("Can't swap this item."); return false; } } if (___m_dragItem == null || !___m_dragItem.m_equipped || __instance.m_dragInventory == grid.GetInventory()) { return true; } MessageHud.instance.ShowMessage((MessageType)2, "Unequip the item before moving it.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(InventoryGui), "UpdateContainer")] public static class InventoryGui_UpdateContainer_Patch { public static bool Prefix(InventoryGui __instance, Player player) { if (!BetterArchery.configQuiverEnabled.Value) { return true; } BetterArchery.isContainerOpen = Object.op_Implicit((Object)(object)__instance.m_currentContainer) && __instance.m_currentContainer.IsOwner(); return true; } } [HarmonyPatch(typeof(InventoryGui), "OnDropOutside")] public static class InventoryGui_OnDropOutside_Patch { public static bool Prefix(GameObject ___m_dragGo, ItemData ___m_dragItem) { if (___m_dragItem == null || !___m_dragItem.m_equipped || !BetterArchery.configQuiverEnabled.Value) { return true; } MessageHud.instance.ShowMessage((MessageType)2, "Unequip the item first.", 0, (Sprite)null); return false; } } [HarmonyPatch(typeof(InventoryGui), "OnCraftPressed")] public static class InventoryGui_OnCraftPressed_Patch { public static void Prefix(InventoryGui __instance) { if (Object.op_Implicit((Object)(object)__instance.m_selectedRecipe.Key)) { __instance.m_craftRecipe = __instance.m_selectedRecipe.Key; if ((Object)(object)__instance.m_craftRecipe != (Object)null && ((Object)__instance.m_craftRecipe).name == "Recipe_ArrowWoodAnywhere") { __instance.m_craftDuration = 7f; } else { __instance.m_craftDuration = 2f; } } } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipeList")] public static class InventoryGui_UpdateRecipeList_Patch { public static void Prefix(InventoryGui __instance, List<Recipe> recipes) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer.GetCurrentCraftingStation())) { Recipe val = recipes.Find((Recipe e) => ((Object)e).name == "Recipe_ArrowWoodAnywhere"); if ((Object)(object)val != (Object)null) { recipes.Remove(val); } } } } [HarmonyPatch(typeof(Inventory), "HaveEmptySlot")] public static class Inventory_HaveEmptySlot_Patch { [HarmonyPriority(800)] public static bool Prefix(Inventory __instance, ref bool __result) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (__instance.GetName() != "Inventory" || !BetterArchery.configQuiverEnabled.Value) { return true; } int num = __instance.m_width * __instance.m_height - 3 - 5; if (__instance.GetHeight() > 5) { num -= 8; } int num2 = __instance.m_inventory.Count; for (int i = 0; i < 3; i++) { Vector2i quiverSlotPosition = BetterArchery.GetQuiverSlotPosition(i); ItemData itemAt = __instance.GetItemAt(quiverSlotPosition.x, quiverSlotPosition.y); num2 -= ((itemAt != null) ? 1 : 0); } __result = num2 < num; return false; } } [HarmonyPatch(typeof(Inventory), "FindEmptySlot")] public static class Inventory_FindEmptySlot_Patch { [HarmonyPriority(800)] public static bool Prefix(Inventory __instance, ref Vector2i __result, bool topFirst, int ___m_height, int ___m_width) { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (__instance.GetName() != "Inventory" || !BetterArchery.configQuiverEnabled.Value) { return true; } if (topFirst) { int num = __instance.GetHeight() - 1; if (__instance.GetHeight() > 5) { num--; } for (int i = 0; i < num; i++) { for (int j = 0; j < ___m_width; j++) { if (__instance.GetItemAt(j, i) == null) { __result = new Vector2i(j, i); return false; } } } } else { int num2 = __instance.GetHeight() - 1; if (__instance.GetHeight() > 5) { num2--; } for (int k = 1; k < num2; k++) { for (int l = 0; l < ___m_width; l++) { if (__instance.GetItemAt(l, k) == null) { __result = new Vector2i(l, k); return false; } } } } __result = new Vector2i(-1, -1); return false; } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class ObjectDB_CopyOtherDB_Patch { public static void Postfix() { BetterArchery.TryRegisterItems(); BetterArchery.TryRegisterRecipes(); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_Patch { public static void Postfix() { BetterArchery.TryRegisterItems(); BetterArchery.TryRegisterRecipes(); } } public static class PlayerBody { public static Transform spine; public static Transform leftHand; public static bool onBowDrawing; } [HarmonyPatch(typeof(Player), "Awake")] public static class Player_Awake_Patch { [HarmonyPriority(0)] private static void Prefix(ref Player __instance) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown if (BetterArchery.configQuiverEnabled.Value) { Traverse.Create((object)__instance).Field("m_inventory").SetValue((object)new Inventory("Inventory", (Sprite)null, 8, ((Humanoid)__instance).m_inventory.m_height + 2)); BetterArchery.Log($"Inventory h: {((Humanoid)__instance).m_inventory.m_height}"); BetterArchery.QuiverRowIndex = ((Humanoid)__instance).m_inventory.m_height - 1; } } } [HarmonyPatch(typeof(Player), "OnSpawned")] public static class ModifyOnSpawned { private static void Prefix(Player __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown TutorialText item = new TutorialText { m_label = "BetterArchery", m_name = "betterarchery", m_text = "Thank you for using this mod! Don't forget to change configurations to get your own taste!", m_topic = "Welcome to BetterArchery" }; if (!Tutorial.instance.m_texts.Contains(item)) { Tutorial.instance.m_texts.Add(item); } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return; } localPlayer.ShowTutorial("betterarchery", false); if (BetterArchery.configQuiverEnabled.Value) { foreach (ItemData equippedItem in ((Humanoid)__instance).m_inventory.GetEquippedItems()) { if (CustomSlotCreator.IsCustomSlotItem(equippedItem)) { equippedItem.m_equipped = true; } equippedItem.m_equipped = true; } } if (!BetterArchery.BowZoomSFXEnabled.Value) { return; } try { BetterArchery.playerAudioSource = ((Component)((Component)localPlayer).transform).gameObject.AddComponent<AudioSource>(); ((Component)((Component)localPlayer).transform).gameObject.AddComponent<ZSFX>(); } catch (Exception ex) { BetterArchery.Log(ex.ToString(), 0); } } } [HarmonyPatch(typeof(Player), "LateUpdate")] public static class Player_LateUpdate_Patch { public static float spineTimer = 0.5f; private static void Postfix(Player __instance, Transform ___m_head, ref Rigidbody ___m_body, ref VisEquipment ___m_visEquipment, ItemData ___m_rightItem, ItemData ___m_leftItem) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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) if ((Object)(object)Player.m_localPlayer != (Object)(object)__instance) { return; } if ((Object)(object)PlayerBody.spine == (Object)null) { PlayerBody.spine = ((IEnumerable<Transform>)((Humanoid)__instance).m_visEquipment.m_bodyModel.bones).SingleOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "Spine")); } if (___m_leftItem != null && (int)___m_leftItem.m_shared.m_itemType == 4 && Object.op_Implicit((Object)(object)___m_body) && PlayerBody.onBowDrawing) { spineTimer = 0.5f; Quaternion rotation = ((Component)((Character)__instance).m_eye).transform.rotation; float num = ((Quaternion)(ref rotation)).eulerAngles.y + 90f; Transform spine = PlayerBody.spine; rotation = PlayerBody.spine.rotation; double num2 = ((Quaternion)(ref rotation)).eulerAngles.x; double num3 = num; rotation = ((Component)((Character)__instance).m_eye).transform.rotation; double num4 = ((Quaternion)(ref rotation)).eulerAngles.x; Quaternion rotation2 = Quaternion.Euler((float)num2, (float)num3, (float)num4); spine.rotation = rotation2; } else if ((double)spineTimer > 0.0) { spineTimer -= Time.deltaTime; Quaternion rotation3 = ((Component)((Character)__instance).m_eye).transform.rotation; float num5 = ((Quaternion)(ref rotation3)).eulerAngles.y + 90f; Transform spine2 = PlayerBody.spine; rotation3 = PlayerBody.spine.rotation; float x2 = ((Quaternion)(ref rotation3)).eulerAngles.x; rotation3 = ((Component)((Character)__instance).m_eye).transform.rotation; spine2.rotation = Quaternion.Euler(x2, num5, ((Quaternion)(ref rotation3)).eulerAngles.x); } } } [HarmonyPatch(typeof(Player), "UseHotbarItem")] public static class Player_UseHotbarItem_Patch { public static bool Prefix(Player __instance) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) int result; if (BetterArchery.configQuiverEnabled.Value) { KeyboardShortcut value = BetterArchery.HoldingKeyCode.Value; if (!string.IsNullOrEmpty(((KeyboardShortcut)(ref value)).Serialize())) { value = BetterArchery.HoldingKeyCode.Value; if (((KeyboardShortcut)(ref value)).Serialize() != "None") { value = BetterArchery.HoldingKeyCode.Value; result = ((!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey)) ? 1 : 0); goto IL_0061; } } } result = 1; goto IL_0061; IL_0061: return (byte)result != 0; } } [HarmonyPatch(typeof(Player), "QueueUnequipAction")] public static class Player_QueueUnequipAction_Patch { public static bool Prefix(ItemData item, Player __instance) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (!BetterArchery.configQuiverEnabled.Value || !((Object)item.m_dropPrefab).name.Contains("Quiver")) { return true; } foreach (ItemData item2 in ((Humanoid)Player.m_localPlayer).m_inventory.m_inventory) { if (BetterArchery.IsQuiverSlot(item2.m_gridPos) && (double)item2.GetWeight() > 0.0) { MessageHud.instance.ShowMessage((MessageType)2, "Empty the quiver first.", 0, (Sprite)null); return false; } } return true; } } [HarmonyPatch(typeof(Player), "SetControls")] public static class Player_SetControls_Patch { private static void Prefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun) { //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_002a: Unknown result type (might be due to invalid IL or missing references) if (!BetterArchery.configBowZoomEnabled.Value) { return; } if (attackHold) { KeyboardShortcut value = BetterArchery.BowDrawCancelKey.Value; blockHold = Input.GetKey(((KeyboardShortcut)(ref value)).MainKey); return; } ItemData leftItem = ((Humanoid)__instance).GetLeftItem(); if (leftItem != null && ((Object)leftItem.m_dropPrefab).name.Contains("Bow") && BetterArchery.__ZoomState == BetterArchery.ZoomState.ZoomingIn) { blockHold = false; } } } [HarmonyPatch(typeof(GameCamera), "GetCameraPosition")] public static class Player_GameCamera_Patch { [HarmonyPriority(100)] private static void Postfix(GameCamera __instance, float dt, Vector3 pos, Quaternion rot) { if (!((Object)(object)__instance == (Object)null) && BetterArchery.configBowZoomEnabled.Value && (double)BetterArchery.__BaseFov == 0.0) { BetterArchery.__BaseFov = __instance.m_fov; } } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] public static class Player_GameCamera_UpdateCamera { [HarmonyPriority(0)] public static void Prefix(GameCamera __instance) { if (BetterArchery.configBowZoomEnabled.Value && (BetterArchery.__ZoomState == BetterArchery.ZoomState.ZoomingOut || BetterArchery.__ZoomState == BetterArchery.ZoomState.ZoomingIn)) { __instance.m_fov = BetterArchery.__NewZoomFov; } } } [HarmonyPatch(typeof(Hud), "UpdateCrosshair")] [HarmonyPriority(0)] public static class Player_UpdateCrosshair_Patch { private static void Postfix(Hud __instance, Player player, float bowDrawPercentage) { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Invalid comparison between Unknown and I4 //IL_014c: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)__instance.m_crosshair).enabled != BetterArchery.IsCrosshairVisible.Value) { ((Behaviour)__instance.m_crosshair).enabled = BetterArchery.IsCrosshairVisible.Value; } if (((Behaviour)__instance.m_crosshairBow).enabled != BetterArchery.IsBowCrosshairVisible.Value) { ((Behaviour)__instance.m_crosshairBow).enabled = BetterArchery.IsBowCrosshairVisible.Value; } PlayerBody.onBowDrawing = (double)bowDrawPercentage > 0.10000000149011612; if (BetterArchery.BowDrawMovementSpeedReductionEnabled.Value) { if ((double)bowDrawPercentage > 0.10000000149011612) { ((Character)player).SetWalk(true); BetterArchery.speedReduction = true; } else if (((Character)player).GetWalk() && BetterArchery.speedReduction) { BetterArchery.speedReduction = false; ((Character)player).SetWalk(false); } } if (!BetterArchery.configBowZoomEnabled.Value || (double)BetterArchery.__BaseFov == 0.0) { return; } ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon(); if (currentWeapon == null || (int)currentWeapon.m_shared.m_itemType != 4) { ZoomOut(); return; } float num = (float)(2.0 * (1.0 - (double)((Character)player).GetSkillFactor(currentWeapon.m_shared.m_skillType))); KeyboardShortcut value = BetterArchery.BowZoomKey.Value; bool key = Input.GetKey(((KeyboardShortcut)(ref value)).MainKey); if (BetterArchery.__ZoomState == BetterArchery.ZoomState.ZoomingIn && !BetterArchery.zoomSFX) { BetterArchery.PlayCustomSFX("inhale", checkIfPlaying: false); BetterArchery.zoomSFX = true; } else if (BetterArchery.__ZoomState == BetterArchery.ZoomState.ZoomingOut && BetterArchery.zoomSFX) { BetterArchery.PlayCustomSFX("exhale", checkIfPlaying: false); BetterArchery.zoomSFX = false; } if (BetterArchery.AutomaticBowZoom.Value) { if ((double)bowDrawPercentage > 0.009999999776482582) { BetterArchery.ZoomInTimer += Time.deltaTime; BetterArchery.__ZoomState = BetterArchery.ZoomState.ZoomingIn; float num2 = (((double)BetterArchery.BowZoomConstantTime.Value <= 0.0) ? Mathf.InverseLerp(0.05f, num, BetterArchery.ZoomInTimer) : Mathf.InverseLerp(0.05f, BetterArchery.BowZoomConstantTime.Value, BetterArchery.ZoomInTimer)); GameCamera.instance.m_fov = (BetterArchery.__LastZoomFov = Mathf.Lerp(BetterArchery.__BaseFov, BetterArchery.__BaseFov / BetterArchery.BowZoomFactor.Value, num2)); BetterArchery.__NewZoomFov = (BetterArchery.__LastZoomFov = Mathf.Lerp(BetterArchery.__BaseFov, BetterArchery.__BaseFov / BetterArchery.BowZoomFactor.Value, num2)); return; } ZoomOut(); } if (key) { if ((double)bowDrawPercentage <= 0.009999999776482582) { BetterArchery.ZoomOutDelayTimer += Time.deltaTime; if (!((double)BetterArchery.ZoomOutDelayTimer <= (double)BetterArchery.StayInZoomTime.Value)) { ZoomOut(); } } else { BetterArchery.ZoomInTimer += Time.deltaTime; BetterArchery.ZoomOutDelayTimer = 0f; BetterArchery.__ZoomState = BetterArchery.ZoomState.ZoomingIn; float num3 = (((double)BetterArchery.BowZoomConstantTime.Value <= 0.0) ? Mathf.InverseLerp(0.05f, num, BetterArchery.ZoomInTimer) : Mathf.InverseLerp(0.05f, BetterArchery.BowZoomConstantTime.Value, BetterArchery.ZoomInTimer)); GameCamera.instance.m_fov = (BetterArchery.__LastZoomFov = Mathf.Lerp(BetterArchery.__BaseFov, BetterArchery.__BaseFov / BetterArchery.BowZoomFactor.Value, num3)); BetterArchery.__NewZoomFov = (BetterArchery.__LastZoomFov = Mathf.Lerp(BetterArchery.__BaseFov, BetterArchery.__BaseFov / BetterArchery.BowZoomFactor.Value, num3)); } } else { BetterArchery.ZoomOutDelayTimer = 1f; ZoomOut(); } } public static void ZoomOut() { if (BetterArchery.__ZoomState != 0) { if (BetterArchery.__ZoomState == BetterArchery.ZoomState.ZoomingIn) { BetterArchery.__ZoomState = BetterArchery.ZoomState.ZoomingOut; BetterArchery.ZoomOutTimer = 0f; BetterArchery.ZoomInTimer = 0f; } else { BetterArchery.ZoomOutTimer += Time.deltaTime; if ((double)BetterArchery.ZoomOutTimer > 1.0) { GameCamera.instance.m_fov = BetterArchery.__BaseFov; BetterArchery.__ZoomState = BetterArchery.ZoomState.Fixed; BetterArchery.ZoomOutDelayTimer = 0f; return; } } float num = Mathf.InverseLerp(0f, 0.3f, BetterArchery.ZoomOutTimer); GameCamera.instance.m_fov = Mathf.Lerp(BetterArchery.__LastZoomFov, BetterArchery.__BaseFov, num); BetterArchery.__NewZoomFov = Mathf.Lerp(BetterArchery.__LastZoomFov, BetterArchery.__BaseFov, num); } else if ((double)GameCamera.instance.m_fov != (double)BetterArchery.__BaseFov) { GameCamera.instance.m_fov = BetterArchery.__BaseFov; } } } [HarmonyPatch(typeof(Player), "CreateTombStone")] public static class Player_CreateTombStone_Patch { public static bool Prefix(Player __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if (((Humanoid)__instance).GetInventory().GetAllItems().Count == 0 || !BetterArchery.IsQuiverEquipped()) { return true; } GameObject val = Object.Instantiate<GameObject>(__instance.m_tombstone, ((Character)__instance).GetCenterPoint() + Vector3.up + ((Component)__instance).transform.forward * -0.5f, ((Component)__instance).transform.rotation); TombStone component = val.GetComponent<TombStone>(); PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); string name = playerProfile.GetName(); long playerID = playerProfile.GetPlayerID(); component.Setup(name + "'s Quiver", playerID); Inventory inventory = val.GetComponent<Container>().GetInventory(); Inventory inventory2 = ((Humanoid)__instance).GetInventory(); List<ItemData> list = new List<ItemData>(); foreach (ItemData item in inventory2.m_inventory) { if (!BetterArchery.IsQuiverSlot(item.m_gridPos)) { list.Add(item); continue; } Vector2i val2 = inventory.FindEmptySlot(false); inventory.AddItem(item, item.m_stack, val2.x, val2.y); } inventory2.m_inventory = list; inventory2.Changed(); inventory.Changed(); return true; } } [HarmonyPatch(typeof(Projectile), "Setup")] public static class RetrieveArrows { public static bool Prefix(ref Projectile __instance, Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemData item) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || item == null) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)owner != (Object)(object)Player.m_localPlayer || !((Object)__instance).name.Contains("bow_projectile") || (int)item.m_shared.m_itemType != 4) { return true; } if (BetterArchery.configArrowImprovementsEnabled.Value) { __instance.m_gravity = BetterArchery.ArrowGravity.Value; } if (!BetterArchery.configRetrievableArrowsEnabled.Value) { return true; } string arrowType = ((Object)((Humanoid)localPlayer).GetAmmoItem().m_dropPrefab).name; if (string.IsNullOrEmpty(arrowType)) { return true; } Arrow arrow = BetterArchery.ArrowRetrieves.Find((Arrow e) => e.SpawnArrow == arrowType); if (arrow == null) { return true; } float num = Random.Range(0f, 1f); BetterArchery.Log($"m_dropPrefab: {arrowType}, x.SpawnChance: {arrow.SpawnChance}, x.SpawnArrow: {arrow.SpawnArrow}"); BetterArchery.Log($"spawnChance: {num}, currentArrow.SpawnChance: {arrow.SpawnChance}"); if (BetterArchery.ArrowRetrieveOldVersion.Value) { if ((double)num < (double)arrow.SpawnChance) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(arrow.SpawnArrow); __instance.m_spawnOffset = new Vector3(0.5f, 0.05f, -0.5f); __instance.m_spawnOnHitChance = 1f; __instance.m_spawnOnHit = itemPrefab; __instance.m_hideOnHit = ((Component)__instance).gameObject; } else { __instance.m_spawnOnHitChance = 0f; __instance.m_ttl = BetterArchery.ArrowDisappearTime.Value; } } else if ((double)num < (double)arrow.SpawnChance) { GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(arrow.SpawnArrow); Pickable val = ((Component)__instance).gameObject.AddComponent<Pickable>(); val.m_hideWhenPicked = ((Component)__instance).gameObject; val.m_amount = 1; val.m_itemPrefab = itemPrefab2; } else if (BetterArchery.ArrowDisappearOnHit.Value) { __instance.m_hideOnHit = ((Component)__instance).gameObject; } else { __instance.m_stayTTL = BetterArchery.ArrowDisappearTime.Value; if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInChildren<MeshRenderer>())) { ((Renderer)((Component)__instance).GetComponentInChildren<MeshRenderer>()).material.color = Color.black; } } return true; } } [HarmonyPatch(typeof(Projectile), "OnHit")] public static class Projectile_OnHit_Patch { public static void Prefix(Projectile __instance, Collider collider, Vector3 hitPoint, bool water) { if (BetterArchery.ArrowRetrieveOldVersion.Value || !BetterArchery.configRetrievableArrowsEnabled.Value || !Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<Pickable>()) || !((Object)__instance).name.Contains("bow_projectile")) { return; } GameObject val = (Object.op_Implicit((Object)(object)collider) ? Projectile.FindHitObject(collider) : null); bool flag = false; IDestructible val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<IDestructible>() : null); if (val2 != null) { flag = val2 is Character; if (!__instance.IsValidTarget(val2)) { return; } } BoxCollider val3 = ((((Object)__instance).name == "bow_projectile_needle(Clone)") ? ((Component)((Component)((Component)__instance).transform.GetChild(0)).gameObject.transform.GetChild(0)).gameObject.AddComponent<BoxCollider>() : ((!(((Object)__instance).name == "bow_projectile_frost(Clone)")) ? ((Component)((Component)__instance).transform.GetChild(0)).gameObject.AddComponent<BoxCollider>() : ((Component)((Component)__instance).transform.GetChild(3)).gameObject.AddComponent<BoxCollider>())); if ((Object)(object)val3 != (Object)null) { ((Collider)val3).enabled = true; __instance.m_stayTTL = BetterArchery.ArrowDisappearTime.Value; } } } [HarmonyPatch(typeof(Attack), "FireProjectileBurst")] public static class Attack_FireProjectileBurst_Patch { public static bool Prefix(ref Attack __instance) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 if (!((Character)__instance.m_character).IsPlayer() || !BetterArchery.configArrowImprovementsEnabled.Value) { return true; } ItemData ammoItem = ((Humanoid)Player.m_localPlayer).m_ammoItem; ItemData leftItem = ((Humanoid)Player.m_localPlayer).GetLeftItem(); if (leftItem == null || (int)leftItem.m_shared.m_itemType != 4 || ammoItem == null) { return true; } __instance.m_projectileVel = BetterArchery.ArrowVelocity.Value; if ((double)BetterArchery.ArrowAccuracy.Value >= 0.0) { __instance.m_projectileAccuracy = BetterArchery.ArrowAccuracy.Value; } return true; } } [HarmonyPatch(typeof(Attack), "GetProjectileSpawnPoint")] public static class Attack_GetProjectileSpawnPoint_Patch { public static void Postfix(ref Attack __instance, ref Vector3 spawnPoint, ref Vector3 aimDir) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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) if (!((Character)__instance.m_character).IsPlayer() || !BetterArchery.configArrowImprovementsEnabled.Value) { return; } ItemData leftItem = ((Humanoid)Player.m_localPlayer).GetLeftItem(); if (leftItem == null || (int)leftItem.m_shared.m_itemType != 4) { return; } Transform leftHand = __instance.m_character.m_visEquipment.m_leftHand; Transform transform = ((Component)__instance.m_character).transform; spawnPoint = leftHand.position; aimDir = __instance.m_character.GetAimDir(spawnPoint); if ((double)aimDir.y <= -0.800000011920929) { Transform attackOrigin = __instance.GetAttackOrigin(); spawnPoint = attackOrigin.position + transform.up * __instance.m_attackHeight + transform.forward * 0.7f + transform.right * __instance.m_attackOffset; aimDir = __instance.m_character.GetAimDir(spawnPoint); } if (__instance.m_useCharacterFacing) { Vector3 forward = Vector3.forward; if (__instance.m_useCharacterFacingYAim) { forward.y = aimDir.y; } aimDir = transform.TransformDirection(forward); } ItemData ammoItem = ((Humanoid)Player.m_localPlayer).m_ammoItem; if (ammoItem != null && Object.op_Implicit((Object)(object)ammoItem.m_shared.m_attack.m_attackProjectile)) { aimDir += BetterArchery.ArrowAimDir.Value; } } } [HarmonyPatch(typeof(Humanoid), "OnDamaged")] public static class Humanoid_OnDamaged_Patch { public static void Postfix(ref Humanoid __instance, HitData hit) { if (Object.op_Implicit((Object)(object)__instance) && hit.HaveAttacker() && hit.GetAttacker().IsPlayer() && BetterArchery.ShowSneakDamage.Value) { BetterArchery.Log($"(Humanoid) - __instance.m_name: {((Character)__instance).m_name}, __instance.InAttack(): {((Character)__instance).InAttack()}, __instance.m_baseAI.IsAlerted(): {((Character)__instance).m_baseAI.IsAlerted()}, __instance.m_baseAI.m_alerted: {((Character)__instance).m_baseAI.m_alerted}"); BetterArchery.Log($"(Humanoid) - GetTotalPhysicalDamage: {hit.GetTotalPhysicalDamage()}, GetTotalDamage: {hit.GetTotalDamage()}"); if (!((Character)__instance).InAttack() && !((Character)__instance).m_baseAI.IsAlerted()) { hit.GetAttacker().Message((MessageType)1, string.Format("<size=25>Sneak attack for {0}X ({1}) damage!</size>", hit.m_backstabBonus, hit.GetTotalDamage().ToString("0.0")), 0, (Sprite)null); } } } } [HarmonyPatch(typeof(Character), "OnDamaged")] public static class Character_OnDamaged_Patch { public static void Postfix(ref Character __instance, HitData hit) { if (Object.op_Implicit((Object)(object)__instance) && hit.HaveAttacker() && hit.GetAttacker().IsPlayer() && BetterArchery.ShowSneakDamage.Value) { BetterArchery.Log($"(Character) - __instance.m_name: {__instance.m_name}, __instance.InAttack(): {__instance.InAttack()}, __instance.m_baseAI.IsAlerted(): {__instance.m_baseAI.IsAlerted()}, __instance.m_baseAI.m_alerted: {__instance.m_baseAI.m_alerted}"); BetterArchery.Log($"(Character) - GetTotalPhysicalDamage: {hit.GetTotalPhysicalDamage()}, GetTotalDamage: {hit.GetTotalDamage()}"); if (!__instance.InAttack() && !__instance.m_baseAI.IsAlerted()) { hit.GetAttacker().Message((MessageType)1, string.Format("<size=25>Sneak attack for {0}X ({1}) damage!</size>", hit.m_backstabBonus, hit.GetTotalDamage().ToString("0.0")), 0, (Sprite)null); } } } } internal class Tombstone { [HarmonyPatch(typeof(TombStone), "OnTakeAllSuccess")] [HarmonyPriority(0)] public static class TombStone_OnTakeAllSuccess_Patch { public static void Postfix() { //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Inventory inventory = ((Humanoid)localPlayer).m_inventory; BetterArchery.Log("Recovered Tombstone Items, verifying inventory..."); List<ItemData> list = new List<ItemData>(); for (int num = inventory.m_inventory.Count - 1; num >= 0; num--) { ItemData val = inventory.m_inventory[num]; if (val.m_gridPos.x < 0 || val.m_gridPos.x >= inventory.m_width || val.m_gridPos.y < 0 || val.m_gridPos.y >= 5) { string text = Localization.instance.Localize(val.m_shared.m_name) + ((val.m_stack > 1) ? $" x{val.m_stack}" : ""); BetterArchery.Log($"> Item Outside Inventory Grid! ({text}, <{val.m_gridPos.x},{val.m_gridPos.y}>)"); inventory.RemoveItem(val); if (!inventory.AddItem(val)) { BetterArchery.Log("> Could not add item to inventory, item dropped! (" + text + ")"); list.Add(val); ItemDrop.DropItem(val, val.m_stack, ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 2f + Vector3.up, Quaternion.identity); } } } if (list.Count > 0) { string text2 = "Not enough space in inventory, Items Dropped: " + string.Join(", ", list.Select((ItemData x) => Localization.instance.Localize(x.m_shared.m_name) + ((x.m_stack > 1) ? $" x{x.m_stack}" : ""))); ((Character)localPlayer).Message((MessageType)2, text2, 0, (Sprite)null); BetterArchery.Log(text2); } else { BetterArchery.Log("> No issues!"); } } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Patch { public static bool Prefix(ZNetScene __instance) { BetterArchery.TryRegisterPrefabs(__instance); return true; } public static void Postfix(ZNetScene __instance) { BetterArchery.TryCreateCustomSlot(__instance); BetterArchery.TryCreateCustomSFX(); } } public static class PlayerExtensions { public static ZDO GetZDO(this Player player) { return ((Character)player).m_nview.GetZDO(); } } } namespace Common { [Serializable] public class RecipeRequirementConfig { public string item = ""; public int amount = 1; } [Serializable] public class RecipeConfig { public string name = ""; public string item = ""; public int amount = 1; public string craftingStation = ""; public int minStationLevel = 1; public bool enabled = true; public string repairStation = ""; public List<RecipeRequirementConfig> resources = new List<RecipeRequirementConfig>(); } [Serializable] public class RecipesConfig { public List<RecipeConfig> recipes = new List<RecipeConfig>(); } internal class CustomSlotItem : MonoBehaviour { public string m_slotName; } public static class CustomSlotCreator { public static readonly Dictionary<Humanoid, Dictionary<string, ItemData>> customSlotItemData = new Dictionary<Humanoid, Dictionary<string, ItemData>>(); public static string GetCustomSlotName(ItemData item) { return item.m_dropPrefab.GetComponent<CustomSlotItem>().m_slotName; } public static bool IsCustomSlotItem(ItemData item) { return item != null && Object.op_Implicit((Object)(object)item.m_dropPrefab) && Object.op_Implicit((Object)(object)item.m_dropPrefab.GetComponent<CustomSlotItem>()); } public static ItemData GetPrefabItemData(Humanoid humanoid, string slotName) { return (!DoesSlotExist(humanoid, slotName)) ? null : customSlotItemData[humanoid][slotName].m_dropPrefab.GetComponent<ItemDrop>().m_itemData; } public static ItemData GetSlotItem(Humanoid humanoid, string slotName) { return DoesSlotExist(humanoid, slotName) ? customSlotItemData[humanoid][slotName] : null; } public static void SetSlotItem(Humanoid humanoid, string slotName, ItemData item) { customSlotItemData[humanoid][slotName] = item; } public static bool DoesSlotExist(Humanoid humanoid, string slotName) { return customSlotItemData[humanoid] != null && customSlotItemData[humanoid].ContainsKey(slotName); } public static bool IsSlotOccupied(Humanoid humanoid, string slotName) { return customSlotItemData[humanoid] != null && customSlotItemData[humanoid].ContainsKey(slotName) && customSlotItemData[humanoid][slotName] != null; } public static void ApplyCustomSlotItem(GameObject prefab, string slotName) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)prefab.GetComponent<CustomSlotItem>())) { prefab.AddComponent<CustomSlotItem>(); } prefab.GetComponent<CustomSlotItem>().m_slotName = slotName; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_itemType = (ItemType)0; Debug.Log((object)("[CustomSlotCreator] Created " + slotName + " slot for " + ((Object)prefab).name + ".")); } } public static class PrefabCreator { public static Dictionary<string, CraftingStation> CraftingStations; public static T RequireComponent<T>(GameObject go) where T : Component { T val = go.GetComponent<T>(); if ((Object)(object)val == (Object)null) { val = go.AddComponent<T>(); } return val; } public static void Reset() { CraftingStations = null; } private static void InitCraftingStations() { if (CraftingStations != null) { return; } CraftingStations = new Dictionary<string, CraftingStation>(); foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if ((Object)(object)recipe.m_craftingStation != (Object)null && !CraftingStations.ContainsKey(((Object)recipe.m_craftingStation).name)) { CraftingStations.Add(((Object)recipe.m_craftingStation).name, recipe.m_craftingStation); } } } public static Recipe CreateRecipe(string name, string itemId, RecipeConfig recipeConfig) { //IL_01ee: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown InitCraftingStations(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemId); if ((Object)(object)itemPrefab == (Object)null) { Debug.LogWarning((object)("[PrefabCreator] Could not find item prefab (" + itemId + ")")); return null; } Recipe val = ScriptableObject.CreateInstance<Recipe>(); ((Object)val).name = name; val.m_amount = recipeConfig.amount; val.m_minStationLevel = recipeConfig.minStationLevel; val.m_item = itemPrefab.GetComponent<ItemDrop>(); val.m_enabled = recipeConfig.enabled; if (!string.IsNullOrEmpty(recipeConfig.craftingStation)) { if (!CraftingStations.ContainsKey(recipeConfig.craftingStation)) { Debug.LogWarning((object)("[PrefabCreator] Could not find crafting station (" + itemId + "): " + recipeConfig.craftingStation)); Debug.Log((object)("[PrefabCreator] Available Stations: " + string.Join(", ", CraftingStations.Keys))); } else { val.m_craftingStation = CraftingStations[recipeConfig.craftingStation]; } } if (!string.IsNullOrEmpty(recipeConfig.repairStation)) { if (!CraftingStations.ContainsKey(recipeConfig.repairStation)) { Debug.LogWarning((object)("[PrefabCreator] Could not find repair station (" + itemId + "): " + recipeConfig.repairStation)); Debug.Log((object)("[PrefabCreator] Available Stations: " + string.Join(", ", CraftingStations.Keys))); } else { val.m_repairStation = CraftingStations[recipeConfig.repairStation]; } } List<Requirement> list = new List<Requirement>(); foreach (RecipeRequirementConfig resource in recipeConfig.resources) { GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab(resource.item); if ((Object)(object)itemPrefab2 == (Object)null) { Debug.LogError((object)("[PrefabCreator] Could not find requirement item (" + itemId + "): " + resource.item)); continue; } list.Add(new Requirement { m_amount = resource.amount, m_resItem = itemPrefab2.GetComponent<ItemDrop>() }); } val.m_resources = list.ToArray(); return val; } public static Recipe AddNewRecipe(string name, string itemId, RecipeConfig recipeConfig) { Recipe val = CreateRecipe(name, itemId, recipeConfig); if (!((Object)(object)val == (Object)null)) { return AddNewRecipe(val); } Debug.LogError((object)("[PrefabCreator] Failed to create recipe (" + name + ")")); return null; } public static Recipe AddNewRecipe(Recipe recipe) { int num = ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == ((Object)recipe).name); if (num > 0) { Debug.Log((object)$"[PrefabCreator] Removed recipe ({((Object)recipe).name}): {num}"); } ObjectDB.instance.m_recipes.Add(recipe); Debug.Log((object)("[PrefabCreator] Added recipe: " + ((Object)recipe).name)); return recipe; } } public static class Utils { public static void PrintObject(object o) { if (o == null) { Debug.Log((object)"null"); } else { Debug.Log((object)(o?.ToString() + ":\n" + GetObjectString(o, " "))); } } public static string GetObjectString(object obj, string indent) { string text = ""; foreach (FieldInfo item in from f in obj.GetType().GetFields() where f.IsPublic select f) { object value = item.GetValue(obj); string text2 = ((value == null) ? "null" : value.ToString()); text = text + "\n" + indent + item.Name + ": " + text2; } return text; } public static Sprite LoadSpriteFromFile(string spritePath) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) spritePath = Path.Combine(Paths.PluginPath, spritePath); if (File.Exists(spritePath)) { byte[] array = File.ReadAllBytes(spritePath); Texture2D val = new Texture2D(20, 20); if (ImageConversion.LoadImage(val, array)) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), default(Vector2), 100f); } } return null; } public static Sprite LoadSpriteFromFile(string modFolder, string iconName) { return LoadSpriteFromFile(Path.Combine(modFolder, iconName)); } public static bool IsServer() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 return ZNet.instance.IsServer() || ZNet.instance.IsDedicated() || (int)SystemInfo.graphicsDeviceType == 4; } } } namespace PocketCloudAgent { internal class <b79db11f-2848-4d8c-bced-958b9e167a46>PocketCloudVersion { public const string version = "2.7.15"; } } namespace Auga { internal static class API { private static readonly Assembly _targetAssembly; public static string RedText; public static string Red; public static string Brown1; public static string Brown2; public static string Brown3; public static string Brown4; public static string Brown5; public static string Brown6; public static string Brown7; public static string Blue; public static string LightBlue; public static string Gold; public static string BrightGold; public static string BrightestGold; public static string GoldDark; public static string Green; static API() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown RedText = "#CD2121"; Red = "#AD1616"; Brown1 = "#EAE1D9"; Brown2 = "#D1C9C2"; Brown3 = "#A39689"; Brown4 = "#706457"; Brown5 = "#2E2620"; Brown6 = "#EAE1D9"; Brown7 = "#181410"; Blue = "#216388"; LightBlue = "#1AACEF"; Gold = "#B98A12"; BrightGold = "#EAA800"; BrightestGold = "#FFBF1B"; GoldDark = "#755608"; Green = "#1B9B37"; _targetAssembly = LoadAssembly(); if (!(_targetAssembly != null)) { return; } Harmony val = new Harmony("mods.randyknapp.auga.API"); foreach (MethodInfo item in from m in typeof(API).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public) where m.Name != "IsLoaded" && m.Name != "LoadAssembly" select m) { val.Patch((MethodBase)item, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(API), "Transpiler", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null); } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> _, MethodBase original) { Type[] parameters = original.GetParameters().Select(delegate(ParameterInfo p) { Type type = p.ParameterType; if (type.Assembly == Assembly.GetExecutingAssembly() && _targetAssembly != null) { type = _targetAssembly.GetType(type.FullName ?? string.Empty); } return type; }).ToArray(); MethodBase originalMethod = _targetAssembly.GetType("Auga.API").GetMethod(original.Name, parameters); int i = 0; while (i < parameters.Length) { yield return new CodeInstruction(OpCodes.Ldarg, (object)i); int num = i + 1; i = num; } yield return new CodeInstruction(OpCodes.Call, (object)originalMethod); yield return new CodeInstruction(OpCodes.Ret, (object)null); } public static Assembly LoadAssembly() { return AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.GetName().Name == "Auga"); } public static bool IsLoaded() { return LoadAssembly() != null; } public static Font GetBoldFont() { return null; } public static Font GetSemiBoldFont() { return null; } public static Font GetRegularFont() { return null; } public static Sprite GetItemBackgroundSprite() { return null; } public static GameObject Panel_Create(Transform parent, Vector2 size, string name, bool withCornerDecoration) { return null; } public static Button SmallButton_Create(Transform parent, string name, string labelText) { return null; } public static Button MediumButton_Create(Transform parent, string name, string labelText) { return null; } public static Button FancyButton_Create(Transform parent, string name, string labelText) { return null; } public static Button SettingsButton_Create(Transform parent, string name, string labelText) { return null; } public static Button DiamondButton_Create(Transform parent, string name, [CanBeNull] Sprite icon) { return null; } public static GameObject Divider_CreateSmall(Transform parent, string name, float width = -1f) { return null; } public static Tuple<GameObject, GameObject> Divider_CreateMedium(Transform parent, string name, float width = -1f) { return null; } public static Tuple<GameObject, GameObject> Divider_CreateLarge(Transform parent, string name, float width = -1f) { return null; } public static void Button_SetTextColors(Button button, Color normal, Color highlighted, Color pressed, Color selected, Color disabled, Color baseTextColor) { } public static void Button_OverrideTextColor(Button button, Color color) { } public static void Tooltip_MakeSimpleTooltip(GameObject obj) { } public static void Tooltip_MakeItem