Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Tidekeeper v0.9.0
plugins/Tidekeeper/Tidekeeper.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Tidekeeper; [HarmonyPatch] internal static class Alerts { private static readonly FieldInfo FNview = AccessTools.Field(typeof(FishingFloat), "m_nview"); private static readonly FieldInfo FRange = AccessTools.Field(typeof(FishingFloat), "m_range"); private static readonly FieldInfo FBaits = AccessTools.Field(typeof(Fish), "m_baits"); private static readonly Func<FishingFloat, string> GetBait = AccessTools.MethodDelegate<Func<FishingFloat, string>>(AccessTools.Method(typeof(FishingFloat), "GetBait", (Type[])null, (Type[])null), (object)null, true); private static AudioClip _bell; private static AudioClip _dull; private static AudioClip _bubble; private static AudioSource _src; private static Player _srcOwner; private static AudioClip _first; private static AudioClip _record; [HarmonyPatch(typeof(FishingFloat), "RPC_Nibble")] [HarmonyPostfix] private static void Nibble(FishingFloat __instance, ZDOID fishID, bool correctBait) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Alerts.Value) { return; } ZNetView val = Fight.G<ZNetView>(FNview, __instance); Player localPlayer = Player.m_localPlayer; if ((Object)(object)val == (Object)null || !val.IsOwner() || (Object)(object)localPlayer == (Object)null || (Object)(object)Fight.GetOwner(__instance) != (Object)(object)localPlayer) { return; } if (correctBait && (Object)(object)ZNetScene.instance != (Object)null) { GameObject val2 = ZNetScene.instance.FindInstance(fishID); Fish val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Fish>() : null); if ((Object)(object)val3 != (Object)null) { Journal.BaitKnown(localPlayer, val3); } } if (correctBait) { Play(localPlayer, Plip(), 0.45f); } else { Play(localPlayer, Dull(), 0.42f); } } internal static void Landed(FishingFloat ff, Player p) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Alerts.Value || (Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)Player.m_localPlayer) { return; } string text = GetBait(ff); string text2 = Baits.Carried(ff); float num = Fight.G<float>(FRange, ff); int num2 = 0; int num3 = 0; Fish[] array = Object.FindObjectsByType<Fish>((FindObjectsSortMode)0); foreach (Fish val in array) { if ((Object)(object)val == (Object)null) { continue; } float num4 = Vector3.Distance(((Component)val).transform.position, ((Component)ff).transform.position); if (num4 <= 10f) { Journal.Seen(p, val); } if (!(num4 > num)) { num2++; if (string.IsNullOrEmpty(text2) ? Takes(val, text) : Baits.Wants(val, text2)) { num3++; } } } if (num3 > 0) { ((MonoBehaviour)ff).StartCoroutine(Bubbles(ff, Mathf.Min(num3, 3))); } Plugin.Detail("[alert] float landed: " + num2 + " fish within " + num.ToString("0") + " m, " + num3 + " take " + (string.IsNullOrEmpty(text2) ? text : ("your baits (" + text2 + ")"))); } private static IEnumerator Bubbles(FishingFloat ff, int n) { yield return (object)new WaitForSeconds(0.6f); for (int i = 0; i < n; i++) { if (!((Object)(object)ff != (Object)null)) { break; } AudioSource s = BubbleSource(ff); s.pitch = Random.Range(0.9f, 1.15f); s.PlayOneShot(Bubble(), 0.9f * Plugin.AlertVolume.Value); yield return (object)new WaitForSeconds(Random.Range(0.35f, 0.6f)); } } private static AudioSource BubbleSource(FishingFloat ff) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown AudioSource component = ((Component)ff).GetComponent<AudioSource>(); if ((Object)(object)component != (Object)null && (Object)(object)component.clip == (Object)null && (Object)(object)component.outputAudioMixerGroup != (Object)null) { return component; } GameObject val = new GameObject("Tidekeeper_Bubbles"); val.transform.SetParent(((Component)ff).transform, false); component = val.AddComponent<AudioSource>(); component.playOnAwake = false; component.spatialBlend = 1f; component.rolloffMode = (AudioRolloffMode)1; component.minDistance = 8f; component.maxDistance = 60f; component.dopplerLevel = 0f; component.outputAudioMixerGroup = Sounds.Mixer(Player.m_localPlayer); return component; } private static AudioClip Bubble() { if ((Object)(object)_bubble != (Object)null) { return _bubble; } int num = 5291; float[] array = new float[num]; float num2 = 0f; for (int i = 0; i < num; i++) { float num3 = (float)i / 44100f; float num4 = 380f + 900f * (num3 / 0.12f); num2 += (float)Math.PI * 2f * num4 / 44100f; float num5 = Mathf.Clamp01(num3 / 0.005f) * Mathf.Exp((0f - num3) / 0.04f); array[i] = Mathf.Sin(num2) * num5 * 0.6f; } _bubble = AudioClip.Create("Tidekeeper_Bubble", num, 1, 44100, false); _bubble.SetData(array, 0); return _bubble; } private static bool Takes(Fish f, string bait) { IList list = ((FBaits != null) ? (FBaits.GetValue(f) as IList) : null); if (list == null || string.IsNullOrEmpty(bait)) { return false; } foreach (object item in list) { BaitSetting val = (BaitSetting)((item is BaitSetting) ? item : null); if (val != null && (Object)(object)val.m_bait != (Object)null && ((Object)val.m_bait).name == bait) { return true; } } return false; } private static void Play(Player p, AudioClip c, float vol) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if ((Object)(object)_src == (Object)null || (Object)(object)_srcOwner != (Object)(object)p) { GameObject val = new GameObject("Tidekeeper_Alert"); val.transform.SetParent(((Component)p).transform, false); _src = val.AddComponent<AudioSource>(); _src.playOnAwake = false; _src.spatialBlend = 0f; _src.outputAudioMixerGroup = Sounds.Mixer(p); _srcOwner = p; } _src.PlayOneShot(c, vol * Plugin.AlertVolume.Value); } private static AudioClip Plip() { if ((Object)(object)_bell != (Object)null) { return _bell; } int num = 6174; float[] array = new float[num]; float num2 = 0f; for (int i = 0; i < num; i++) { float num3 = (float)i / 44100f; float num4 = 820f - 380f * Mathf.Clamp01(num3 / 0.08f); num2 += (float)Math.PI * 2f * num4 / 44100f; float num5 = Mathf.Clamp01(num3 / 0.003f) * Mathf.Exp((0f - num3) / 0.035f); array[i] = Mathf.Sin(num2) * num5 * 0.6f; } _bell = AudioClip.Create("Tidekeeper_Plip", num, 1, 44100, false); _bell.SetData(array, 0); return _bell; } internal static void Fanfare(bool first) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { if (first && (Object)(object)_first == (Object)null) { _first = Chord("Tidekeeper_First", new float[4] { 523f, 659f, 784f, 1047f }); } if (!first && (Object)(object)_record == (Object)null) { _record = Chord("Tidekeeper_Record", new float[2] { 587f, 880f }); } Play(localPlayer, first ? _first : _record, 0.8f); } } private static AudioClip Chord(string name, float[] notes) { int num = (int)(44100f * (0.11f * (float)notes.Length + 0.7f)); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 44100f; float num3 = 0f; for (int j = 0; j < notes.Length; j++) { float num4 = num2 - (float)j * 0.11f; if (!(num4 < 0f)) { float num5 = Mathf.Clamp01(num4 / 0.005f) * Mathf.Exp((0f - num4) / 0.35f); num3 += (Mathf.Sin((float)Math.PI * 2f * notes[j] * num4) * 0.5f + Mathf.Sin((float)Math.PI * 2f * notes[j] * 2f * num4) * 0.12f) * num5; } } array[i] = Mathf.Clamp(num3 * 0.45f, -1f, 1f); } AudioClip val = AudioClip.Create(name, num, 1, 44100, false); val.SetData(array, 0); return val; } private static AudioClip Dull() { if ((Object)(object)_dull == (Object)null) { _dull = Tone("Tidekeeper_Dull", 0.25f, new float[2] { 392f, 196f }, new float[2] { 0.35f, 0.2f }, new float[2] { 0.07f, 0.1f }); } return _dull; } private static AudioClip Tone(string name, float seconds, float[] freq, float[] amp, float[] decay) { int num = (int)(44100f * seconds); float[] array = new float[num]; for (int i = 0; i < num; i++) { float num2 = (float)i / 44100f; float num3 = Mathf.Clamp01(num2 / 0.004f); float num4 = 0f; for (int j = 0; j < freq.Length; j++) { num4 += Mathf.Sin((float)Math.PI * 2f * freq[j] * num2) * amp[j] * Mathf.Exp((0f - num2) / decay[j]); } array[i] = num4 * num3; } AudioClip val = AudioClip.Create(name, num, 1, 44100, false); val.SetData(array, 0); return val; } } [HarmonyPatch] internal static class Baits { private static readonly int BaitsKey = StringExtensionMethods.GetStableHashCode("felih.Tidekeeper.baits"); private static readonly FieldInfo FNview = AccessTools.Field(typeof(FishingFloat), "m_nview"); private static readonly FieldInfo FFishBaits = AccessTools.Field(typeof(Fish), "m_baits"); private static readonly FieldInfo FCharacter = AccessTools.Field(typeof(Attack), "m_character"); private static readonly FieldInfo FWeapon = AccessTools.Field(typeof(Attack), "m_weapon"); private static float _nextNotFor; private static Func<HotkeyBar, int, ItemData> _cdevItemAt; private static readonly FieldInfo FElements = AccessTools.Field(typeof(HotkeyBar), "m_elements"); private static FieldInfo _fGo; private static float _nextHaveLog; private static float _nextPublish; internal static bool IsBait(ItemData it) { if (it != null && (Object)(object)it.m_dropPrefab != (Object)null) { return ((Object)it.m_dropPrefab).name.StartsWith("FishingBait", StringComparison.Ordinal); } return false; } internal static bool Rod(ItemData w) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if (w == null || w.m_shared == null) { return false; } if ((int)w.m_shared.m_skillType == 104) { return true; } if ((Object)(object)w.m_dropPrefab != (Object)null && ((Object)w.m_dropPrefab).name.StartsWith("FishingRod", StringComparison.Ordinal)) { return true; } if (!string.IsNullOrEmpty(w.m_shared.m_ammoType)) { return w.m_shared.m_ammoType.IndexOf("fishingbait", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static bool Mine(Humanoid h, ItemData w) { if (Plugin.AutoBait.Value && (Object)(object)h != (Object)null && (Object)(object)h == (Object)(object)Player.m_localPlayer) { return Rod(w); } return false; } internal static List<ItemData> All(Player p) { List<ItemData> list = new List<ItemData>(); Inventory val = Pouch.InBag(p); ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon(); if (val != null) { foreach (ItemData allItem in val.GetAllItems()) { if (IsBait(allItem) && Tidekeeper.Rod.Takes(currentWeapon, ((Object)allItem.m_dropPrefab).name)) { list.Add(allItem); } } } foreach (ItemData allItem2 in ((Humanoid)p).GetInventory().GetAllItems()) { if (IsBait(allItem2) && Tidekeeper.Rod.Takes(currentWeapon, ((Object)allItem2.m_dropPrefab).name)) { list.Add(allItem2); } } return list; } internal static string Marked(Player p) { string text = Pouch.Mark(Pouch.Find(p)); if (string.IsNullOrEmpty(text)) { return null; } foreach (ItemData item in All(p)) { if (((Object)item.m_dropPrefab).name == text) { return text; } } return null; } private static bool Any(Player p) { Inventory val = Pouch.InBag(p); if (val != null) { foreach (ItemData allItem in val.GetAllItems()) { if (IsBait(allItem)) { return true; } } } foreach (ItemData allItem2 in ((Humanoid)p).GetInventory().GetAllItems()) { if (IsBait(allItem2)) { return true; } } return false; } internal static void NotForThisRod(Player p) { if (!((Object)(object)p == (Object)null) && !(Time.time < _nextNotFor)) { _nextNotFor = Time.time + 3f; ((Character)p).Message((MessageType)2, "The Primitive Fishing Rod only takes basic Fishing Bait", 0, (Sprite)null, false); } } private static string Names(Player p) { string text = Marked(p); if (text != null) { return text; } List<string> list = new List<string>(); foreach (ItemData item in All(p)) { if (!list.Contains(((Object)item.m_dropPrefab).name)) { list.Add(((Object)item.m_dropPrefab).name); } } return string.Join(",", list.ToArray()); } internal static void PatchCdev(Harmony h) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown Type type = AccessTools.TypeByName("CDEV.EquipmentSlots.HotbarAmmo"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "Update", new Type[2] { typeof(HotkeyBar), typeof(Player) }, (Type[])null) : null); MethodInfo methodInfo2 = ((type != null) ? AccessTools.Method(type, "ItemAt", (Type[])null, (Type[])null) : null); if (!(methodInfo == null) && !(methodInfo2 == null)) { _cdevItemAt = (Func<HotkeyBar, int, ItemData>)Delegate.CreateDelegate(typeof(Func<HotkeyBar, int, ItemData>), methodInfo2); h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Baits), "HideRodBox", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Plugin.Detail("[bait] CDEV.EquipmentSlots found: no bait icon above the fishing rod"); } } private static void HideRodBox(HotkeyBar bar) { if (!Plugin.AutoBait.Value || (Object)(object)bar == (Object)null || _cdevItemAt == null || FElements == null || !(FElements.GetValue(bar) is IList list)) { return; } for (int i = 0; i < list.Count; i++) { object obj = list[i]; if (obj == null) { continue; } if (_fGo == null) { _fGo = AccessTools.Field(obj.GetType(), "m_go"); } GameObject val = (GameObject)((_fGo != null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val == (Object)null) && Rod(_cdevItemAt(bar, i))) { Transform val2 = val.transform.Find("CDEV_Ammo"); if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(false); } } } } [HarmonyPrefix] [HarmonyPatch(typeof(Attack), "HaveAmmo")] private static bool Have(Humanoid character, ItemData weapon, ref bool __result) { //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (weapon != null && Time.time >= _nextHaveLog && !string.IsNullOrEmpty(weapon.m_shared.m_ammoType) && weapon.m_shared.m_ammoType.IndexOf("bait", StringComparison.OrdinalIgnoreCase) >= 0) { Plugin.Detail(string.Concat("[bait] weapon ", ((Object)(object)weapon.m_dropPrefab != (Object)null) ? ((Object)weapon.m_dropPrefab).name : "?", ": skill ", weapon.m_shared.m_skillType, ", ammo ", weapon.m_shared.m_ammoType, ", counts as rod ", Rod(weapon))); } if (Rod(weapon) && Time.time >= _nextHaveLog) { _nextHaveLog = Time.time + 1f; Player val = (Player)(object)((character is Player) ? character : null); ItemData val2 = (((Object)(object)val != (Object)null) ? Pouch.Find(val) : null); Inventory val3 = ((val2 != null) ? Pouch.Of(val2) : null); Plugin.Detail("[bait] cast check: automatic " + Plugin.AutoBait.Value + ", local player " + ((Object)(object)character == (Object)(object)Player.m_localPlayer) + ", pouch " + ((val2 == null) ? "none" : ((val3 != null) ? (val3.GetAllItems().Count + " stack(s)") : "unreadable")) + ", baits seen " + (((Object)(object)val != (Object)null) ? All(val).Count : (-1)) + ", worn " + ((character.GetAmmoItem() != null) ? character.GetAmmoItem().m_shared.m_name : "none")); } if (!Mine(character, weapon)) { return true; } __result = All((Player)character).Count > 0; if (!__result && Tidekeeper.Rod.IsPrimitive(weapon) && Any((Player)character)) { NotForThisRod((Player)character); } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(Attack), "EquipAmmoItem")] private static bool NoEquip(Humanoid character, ItemData weapon, ref bool __result) { if (!Mine(character, weapon)) { return true; } __result = true; return false; } [HarmonyPostfix] [HarmonyPatch(typeof(Attack), "FindAmmo")] private static void AnyBait(Humanoid character, ItemData weapon, ref ItemData __result) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (Mine(character, weapon) && __result == null) { List<ItemData> list = All((Player)character); if (list.Count > 0) { __result = list[0]; } } } [HarmonyPriority(0)] [HarmonyPrefix] [HarmonyPatch(typeof(Attack), "UseAmmo")] private static bool NothingUsed(Attack __instance, ref ItemData ammoItem, ref bool __result) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown Humanoid val = Fight.G<Humanoid>(FCharacter, __instance); if (!Mine(val, Fight.G<ItemData>(FWeapon, __instance))) { return true; } Player val2 = (Player)val; ItemData ammoItem2 = ((Humanoid)val2).GetAmmoItem(); List<ItemData> list = All(val2); ammoItem = ((ammoItem2 != null && IsBait(ammoItem2) && ((Humanoid)val2).GetInventory().ContainsItem(ammoItem2)) ? ammoItem2 : ((list.Count > 0) ? list[0] : null)); __result = ammoItem != null; Plugin.Detail("[bait] cast, nothing used up; baits you have: " + Names(val2)); string text = Pouch.Mark(Pouch.Find(val2)); if (!string.IsNullOrEmpty(text) && !Tidekeeper.Rod.Takes(((Humanoid)val2).GetCurrentWeapon(), text)) { NotForThisRod(val2); } else if (ammoItem2 != null && IsBait(ammoItem2) && !Tidekeeper.Rod.Takes(((Humanoid)val2).GetCurrentWeapon(), ((Object)ammoItem2.m_dropPrefab).name)) { NotForThisRod(val2); } return false; } [HarmonyPostfix] [HarmonyPatch(typeof(FishingFloat), "Setup")] private static void Carried(FishingFloat __instance, Character owner) { Publish(__instance, (Player)(object)((owner is Player) ? owner : null)); } [HarmonyPrefix] [HarmonyPatch(typeof(FishingFloat), "FixedUpdate")] private static void Refresh(FishingFloat __instance) { if (!(Time.time < _nextPublish)) { Character obj = Fight.GetOwner(__instance); Player val = (Player)(object)((obj is Player) ? obj : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer)) { _nextPublish = Time.time + 1f; Publish(__instance, val); } } } private static void Publish(FishingFloat ff, Player p) { if ((Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)Player.m_localPlayer || !Plugin.AutoBait.Value) { return; } ZNetView val = Fight.G<ZNetView>(FNview, ff); if (!((Object)(object)val == (Object)null) && val.IsValid() && val.IsOwner()) { string text = Names(p); if (val.GetZDO().GetString(BaitsKey, "") != text) { val.GetZDO().Set(BaitsKey, text); } } } internal static string Carried(FishingFloat ff) { ZNetView val = Fight.G<ZNetView>(FNview, ff); if (!((Object)(object)val != (Object)null) || !val.IsValid()) { return ""; } return val.GetZDO().GetString(BaitsKey, ""); } private static bool OnList(string list, string name) { if (!string.IsNullOrEmpty(list)) { return ("," + list + ",").IndexOf("," + name + ",", StringComparison.Ordinal) >= 0; } return false; } internal static bool Wants(Fish f, string list) { IList list2 = ((FFishBaits != null) ? (FFishBaits.GetValue(f) as IList) : null); if (list2 == null) { return false; } foreach (object item in list2) { BaitSetting val = (BaitSetting)((item is BaitSetting) ? item : null); if (val != null && (Object)(object)val.m_bait != (Object)null && OnList(list, ((Object)val.m_bait).name)) { return true; } } return false; } [HarmonyPatch(typeof(Fish), "TestBate")] [HarmonyPrefix] private static bool Test(Fish __instance, FishingFloat ff, ref bool __result) { string text = Carried(ff); if (string.IsNullOrEmpty(text)) { return true; } IList list = ((FFishBaits != null) ? (FFishBaits.GetValue(__instance) as IList) : null); __result = false; if (list != null) { foreach (object item in list) { BaitSetting val = (BaitSetting)((item is BaitSetting) ? item : null); if (val != null && (Object)(object)val.m_bait != (Object)null && OnList(text, ((Object)val.m_bait).name) && Random.value < val.m_chance) { __result = true; break; } } } return false; } [HarmonyPatch(typeof(FishingFloat), "ReturnBait")] [HarmonyPrefix] [HarmonyPriority(800)] private static bool NoReturn(FishingFloat __instance) { return string.IsNullOrEmpty(Carried(__instance)); } [HarmonyPatch(typeof(FishingFloat), "SetCatch")] [HarmonyPostfix] private static void Hooked(FishingFloat __instance, Fish fish) { if ((Object)(object)fish == (Object)null || string.IsNullOrEmpty(Carried(__instance))) { return; } Character obj = Fight.GetOwner(__instance); Player val = (Player)(object)((obj is Player) ? obj : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return; } IList list = ((FFishBaits != null) ? (FFishBaits.GetValue(fish) as IList) : null); if (list == null) { return; } Inventory val2 = Pouch.InBag(val); foreach (object item in list) { BaitSetting val3 = (BaitSetting)((item is BaitSetting) ? item : null); if (val3 == null || (Object)(object)val3.m_bait == (Object)null) { continue; } Inventory[] array = (Inventory[])(object)new Inventory[2] { val2, ((Humanoid)val).GetInventory() }; foreach (Inventory val4 in array) { if (val4 == null) { continue; } foreach (ItemData allItem in val4.GetAllItems()) { if ((Object)(object)allItem.m_dropPrefab != (Object)null && ((Object)allItem.m_dropPrefab).name == ((Object)val3.m_bait).name) { val4.RemoveItem(allItem, 1); Plugin.Detail("[bait] hooked " + ((Object)fish).name + ": used one " + ((Object)val3.m_bait).name + ((val4 == val2) ? " from the pouch" : " from the bag")); return; } } } } Plugin.Detail("[bait] hooked " + ((Object)fish).name + " but none of its bait was found to use up"); } } internal static class CastHud { private static GUIStyle _label; private static GUIStyle _mark; private static Texture2D _bg; private static Texture2D _fill; private static Texture2D _tick; private static Texture2D _ring; private static Texture2D _dot; internal static void Draw() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) if (!CastTweaks.Drawing(out var pct)) { return; } if (_label == null || (Object)(object)_bg == (Object)null) { _bg = FightHud.Tex(new Color(0.08f, 0.07f, 0.06f, 0.85f)); _fill = FightHud.Tex(new Color(0.95f, 0.72f, 0.3f, 0.95f)); _tick = FightHud.Tex(new Color(1f, 1f, 1f, 0.35f)); _ring = FightHud.Tex(new Color(1f, 0.82f, 0.45f, 0.95f)); _dot = FightHud.Tex(new Color(0f, 0f, 0f, 0.6f)); GUIStyle val = new GUIStyle(GUI.skin.label); val.fontSize = 18; val.fontStyle = (FontStyle)1; val.alignment = (TextAnchor)4; val.normal.textColor = FightHud.Gold; _label = val; GUIStyle val2 = new GUIStyle(GUI.skin.label); val2.fontSize = 16; val2.fontStyle = (FontStyle)1; val2.alignment = (TextAnchor)3; val2.normal.textColor = FightHud.Gold; _mark = val2; } Camera mainCamera = Utils.GetMainCamera(); if (CastTweaks.LastHit && (Object)(object)mainCamera != (Object)null) { Vector3 val3 = mainCamera.WorldToScreenPoint(CastTweaks.LastLanding); if (val3.z > 0f) { float num = (float)Screen.height / 1080f; float x = val3.x; float num2 = (float)Screen.height - val3.y; float num3 = 9f * num; float num4 = 3f * num; GUI.DrawTexture(new Rect(x - num3 - num4, num2 - num3 - num4, 2f * (num3 + num4), 2f * (num3 + num4)), (Texture)(object)_dot); GUI.DrawTexture(new Rect(x - num3, num2 - num3, 2f * num3, num4), (Texture)(object)_ring); GUI.DrawTexture(new Rect(x - num3, num2 + num3 - num4, 2f * num3, num4), (Texture)(object)_ring); GUI.DrawTexture(new Rect(x - num3, num2 - num3, num4, 2f * num3), (Texture)(object)_ring); GUI.DrawTexture(new Rect(x + num3 - num4, num2 - num3, num4, 2f * num3), (Texture)(object)_ring); } } float num5 = (float)Screen.height / 1080f; Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num5, num5, 1f)); float num6 = (float)Screen.width / num5; float num7 = (float)Screen.height / num5; Rect val4 = default(Rect); ((Rect)(ref val4))..ctor((num6 - 340f) / 2f, num7 * 0.62f, 340f, 14f); GUI.DrawTexture(new Rect(((Rect)(ref val4)).x - 3f, ((Rect)(ref val4)).y - 3f, 346f, 20f), (Texture)(object)_bg); GUI.DrawTexture(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y, 340f * Mathf.Clamp01(pct), 14f), (Texture)(object)_fill); for (int i = 1; i < 4; i++) { GUI.DrawTexture(new Rect(((Rect)(ref val4)).x + 340f * (float)i / 4f, ((Rect)(ref val4)).y, 1f, 14f), (Texture)(object)_tick); } string text = "Cast power " + Mathf.RoundToInt(pct * 100f) + "%"; GUI.Label(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y - 30f, 340f, 26f), text, _label); GUI.matrix = matrix; } } [HarmonyPatch] internal static class CastLook { private static readonly FieldInfo FRenderer = AccessTools.Field(typeof(LineConnect), "m_lineRenderer"); private static readonly HashSet<string> Told = new HashSet<string>(); private static readonly Dictionary<string, Material> Plain = new Dictionary<string, Material>(); private static readonly HashSet<Material> Ours = new HashSet<Material>(); [HarmonyPatch(typeof(FishingFloat), "Setup")] [HarmonyPostfix] private static void Dress(FishingFloat __instance, ItemData item) { if ((Object)(object)__instance != (Object)null) { Dress(((Component)__instance).gameObject, item, "float"); } } [HarmonyPatch(typeof(Projectile), "Setup")] [HarmonyPostfix] private static void DressFlying(Projectile __instance, ItemData item) { if ((Object)(object)__instance != (Object)null) { Dress(((Component)__instance).gameObject, item, "flying"); } } private static void Dress(GameObject go, ItemData item, string what) { if (!Plugin.RodParts.Value || item == null || !Parts.Takes(item)) { return; } try { int num = Parts.TierOn(item, Parts.Slot.Line); int num2 = Parts.TierOn(item, Parts.Slot.Hook); if (num > 0) { LineConnect[] componentsInChildren = go.GetComponentsInChildren<LineConnect>(true); foreach (LineConnect lc in componentsInChildren) { Line(lc, num); } } if (num2 > 0) { Renderer[] componentsInChildren2 = go.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren2) { if (val is LineRenderer || val is TrailRenderer || ((object)val).GetType().Name == "ParticleSystemRenderer") { continue; } Material[] sharedMaterials = val.sharedMaterials; for (int k = 0; k < sharedMaterials.Length; k++) { if ((Object)(object)sharedMaterials[k] != (Object)null) { sharedMaterials[k] = FloatMetal(sharedMaterials[k], num2); } } val.sharedMaterials = sharedMaterials; if (Told.Add(what + ((Object)val).name)) { Plugin.Detail("[rodlook] cast " + what + ": " + ((object)val).GetType().Name + " " + ((Object)val).name + ", texture " + (sharedMaterials.Length > 0 && (Object)(object)sharedMaterials[0] != (Object)null && (Object)(object)sharedMaterials[0].mainTexture != (Object)null)); } } } Plugin.Detail("[rodlook] cast " + what + ": line tier " + num + ", float tier " + num2); } catch (Exception ex) { Plugin.Detail("[rodlook] cast look: " + ex.Message); } } private static Material FloatMetal(Material src, int tier) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) if (Ours.Contains(src)) { return src; } if ((Object)(object)src.mainTexture != (Object)null) { Material val = RodLook.Metal(src, tier, 4); Ours.Add(val); return val; } string key = ((Object)src).GetInstanceID() + "_" + tier; if (Plain.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } RodLook.Look look = RodLook.LookOf(RodLook.MetalIndex(tier), 4); value = new Material(src); ((Object)value).name = "TK " + ((Object)src).name + " " + tier; Color val2 = (src.HasProperty("_Color") ? src.GetColor("_Color") : Color.white); float num = 0.3f * val2.r + 0.59f * val2.g + 0.11f * val2.b; float num2 = Mathf.Min(1.2f, look.Floor + num * look.Span); Color val3 = Color.Lerp(val2, look.Color * num2, Mathf.Max(0.6f, look.Tint)); val3.a = val2.a; if (value.HasProperty("_Color")) { value.SetColor("_Color", val3); } if (value.HasProperty("_Glossiness")) { value.SetFloat("_Glossiness", look.Gloss); } if (value.HasProperty("_Metallic")) { value.SetFloat("_Metallic", look.Shine); } Plain[key] = value; Ours.Add(value); return value; } private static void Line(LineConnect lc, int tier) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) LineRenderer val = (LineRenderer)(((Object)(object)lc != (Object)null && FRenderer != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null) { val = (((Object)(object)lc != (Object)null) ? ((Component)lc).GetComponent<LineRenderer>() : null); } if (!((Object)(object)val == (Object)null)) { RodLook.Look look = RodLook.LookOf(RodLook.MetalIndex(tier), 1); Color val2 = look.Color; if (look.Glow > 0f) { val2 *= 1f + look.Glow; } val2.a = 1f; Material material = ((Renderer)val).material; if (material.HasProperty("_Color")) { material.SetColor("_Color", val2); } if (material.HasProperty("_TintColor")) { material.SetColor("_TintColor", val2); } if (look.Glow > 0f && material.HasProperty("_EmissionColor")) { material.EnableKeyword("_EMISSION"); material.SetColor("_EmissionColor", look.Color * look.Glow); } val.startColor = val2; val.endColor = val2; if (Plugin.DetailedLog.Value) { Plugin.Detail("[rodlook] cast line shader " + ((Object)material.shader).name + ": color " + material.HasProperty("_Color") + ", tint " + material.HasProperty("_TintColor") + ", emission " + material.HasProperty("_EmissionColor")); } } } } internal class FloatInfo : MonoBehaviour { public float PullSpeed; public float PullSpeedMax; public bool Gliding; public float CastAt; public bool Landed; public float Predicted; } [HarmonyPatch] internal static class CastTweaks { internal struct Flight { public float Gravity; public float Drag; public float Radius; public float Ttl; public bool Water; public bool SpawnOnTtl; public int Mask; } internal const float DrawSeconds = 2.5f; private const float GlideSpeed = 1.2f; private const float GlideSpeedMax = 2f; private const LiquidType AnyLiquid = (LiquidType)10; private const float HookWindow = 1f; private static readonly FieldInfo FPullSpeed = AccessTools.Field(typeof(FishingFloat), "m_pullLineSpeed"); private static readonly FieldInfo FPullSpeedMax = AccessTools.Field(typeof(FishingFloat), "m_pullLineSpeedMaxSkill"); private static readonly FieldInfo FNview = AccessTools.Field(typeof(FishingFloat), "m_nview"); private static readonly FieldInfo FBody = AccessTools.Field(typeof(FishingFloat), "m_body"); private static readonly Func<FishingFloat, string> GetBait = AccessTools.MethodDelegate<Func<FishingFloat, string>>(AccessTools.Method(typeof(FishingFloat), "GetBait", (Type[])null, (Type[])null), (object)null, true); internal static float LastPct; internal static float LastPredicted; internal static Vector3 LastLanding; internal static bool LastHit; private static readonly FieldInfo FVel = AccessTools.Field(typeof(Attack), "m_projectileVel"); private static readonly FieldInfo FVelMin = AccessTools.Field(typeof(Attack), "m_projectileVelMin"); private static readonly FieldInfo FVelCurve = AccessTools.Field(typeof(Attack), "m_drawVelocityCurve"); private static readonly FieldInfo FLaunchAngle = AccessTools.Field(typeof(Attack), "m_launchAngle"); private static readonly FieldInfo FHeight = AccessTools.Field(typeof(Attack), "m_attackHeight"); private static readonly FieldInfo FRange = AccessTools.Field(typeof(Attack), "m_attackRange"); private static readonly FieldInfo FOffset = AccessTools.Field(typeof(Attack), "m_attackOffset"); private static readonly FieldInfo FProjectile = AccessTools.Field(typeof(Attack), "m_attackProjectile"); private static readonly FieldInfo FJoint = AccessTools.Field(typeof(Attack), "m_attackOriginJoint"); private static readonly FieldInfo FBowDraw = AccessTools.Field(typeof(Attack), "m_bowDraw"); private static readonly FieldInfo FRandomVel = AccessTools.Field(typeof(Attack), "m_randomVelocity"); private static readonly FieldInfo FUseFacing = AccessTools.Field(typeof(Attack), "m_useCharacterFacing"); private static readonly FieldInfo FUseFacingY = AccessTools.Field(typeof(Attack), "m_useCharacterFacingYAim"); private static readonly FieldInfo PGravity = AccessTools.Field(typeof(Projectile), "m_gravity"); private static readonly FieldInfo PDrag = AccessTools.Field(typeof(Projectile), "m_drag"); private static readonly FieldInfo PRayRadius = AccessTools.Field(typeof(Projectile), "m_rayRadius"); private static readonly FieldInfo PCanHitWater = AccessTools.Field(typeof(Projectile), "m_canHitWater"); private static readonly FieldInfo PTtl = AccessTools.Field(typeof(Projectile), "m_ttl"); private static readonly FieldInfo PSpawnOnTtl = AccessTools.Field(typeof(Projectile), "m_spawnOnTtl"); private static readonly FieldInfo PMask = AccessTools.Field(typeof(Projectile), "s_rayMaskSolids"); private static readonly Func<Humanoid, Vector3, Vector3> AimDir = AccessTools.MethodDelegate<Func<Humanoid, Vector3, Vector3>>(AccessTools.Method(typeof(Humanoid), "GetAimDir", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<Humanoid, ItemData, ItemData> FindAmmo = AccessTools.MethodDelegate<Func<Humanoid, ItemData, ItemData>>(AccessTools.Method(typeof(Attack), "FindAmmo", (Type[])null, (Type[])null), (object)null, true); internal static readonly Func<Vector3, float, LiquidType, float> LiquidLevel = AccessTools.MethodDelegate<Func<Vector3, float, LiquidType, float>>(AccessTools.Method(typeof(Floating), "GetLiquidLevel", (Type[])null, (Type[])null), (object)null, true); private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[32]; private static string _flightLogged = ""; private static Transform _origin; private static GameObject _originOf; private static string _originJoint; private static readonly FieldInfo FNibbler = AccessTools.Field(typeof(FishingFloat), "m_nibbler"); private static readonly FieldInfo FNibbleTime = AccessTools.Field(typeof(FishingFloat), "m_nibbleTime"); private static Vector3 _thrownAt; private static Vector3 _ourLanding; private static float _thrownTime = -10f; internal static float PullSpeed(FishingFloat ff) { FloatInfo component = ((Component)ff).GetComponent<FloatInfo>(); if (!((Object)(object)component != (Object)null)) { return Fight.G<float>(FPullSpeed, ff); } return component.PullSpeed; } internal static float PullSpeedMax(FishingFloat ff) { FloatInfo component = ((Component)ff).GetComponent<FloatInfo>(); if (!((Object)(object)component != (Object)null)) { return Fight.G<float>(FPullSpeedMax, ff); } return component.PullSpeedMax; } [HarmonyPostfix] [HarmonyPatch(typeof(FishingFloat), "Awake")] private static void Remember(FishingFloat __instance) { FloatInfo floatInfo = ((Component)__instance).gameObject.AddComponent<FloatInfo>(); floatInfo.PullSpeed = Fight.G<float>(FPullSpeed, __instance); floatInfo.PullSpeedMax = Fight.G<float>(FPullSpeedMax, __instance); floatInfo.CastAt = Time.time; } internal static bool EmptyLine(FishingFloat ff) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) FloatInfo component = ((Component)ff).GetComponent<FloatInfo>(); if ((Object)(object)component == (Object)null) { return true; } bool flag = Plugin.Cast.Value && (Object)(object)Fight.GetCatch(ff) == (Object)null; if (flag != component.Gliding) { component.Gliding = flag; FPullSpeed.SetValue(ff, flag ? 1.2f : component.PullSpeed); FPullSpeedMax.SetValue(ff, flag ? 2f : component.PullSpeedMax); } Rigidbody val; ZNetView val2; Character val3; int num2; if (!component.Landed && Time.time - component.CastAt > 0.15f) { val = Fight.G<Rigidbody>(FBody, ff); val2 = Fight.G<ZNetView>(FNview, ff); val3 = Fight.GetOwner(ff); float num = LiquidLevel(((Component)ff).transform.position, 1f, (LiquidType)0); if (!(((Component)ff).transform.position.y <= num + 0.15f)) { if (!val.isKinematic) { Vector3 linearVelocity = val.linearVelocity; if (((Vector3)(ref linearVelocity)).magnitude < 0.5f) { num2 = ((Time.time - component.CastAt > 0.5f) ? 1 : 0); goto IL_0137; } } num2 = 0; } else { num2 = 1; } goto IL_0137; } goto IL_022c; IL_022c: return true; IL_0137: bool flag2 = (byte)num2 != 0; if ((Object)(object)val != (Object)null && (Object)(object)val3 != (Object)null && (Object)(object)val2 != (Object)null && val2.IsOwner() && flag2) { component.Landed = true; Plugin.Detail("[cast] float landed " + Flat(((Component)val3).transform.position, ((Component)ff).transform.position).ToString("0.0") + " m away (predicted " + component.Predicted.ToString("0.0") + " m), " + (Time.time - component.CastAt).ToString("0.0") + " s after the cast"); FishList.DumpWater(((Component)ff).transform.position); Alerts.Landed(ff, (Player)(object)((val3 is Player) ? val3 : null)); } goto IL_022c; } [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] private static void SlowDraw(ObjectDB __instance) { if (Plugin.Cast.Value) { GameObject itemPrefab = __instance.GetItemPrefab("FishingRod"); ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if (!((Object)(object)val == (Object)null)) { Attack attack = val.m_itemData.m_shared.m_attack; Plugin.Detail("[cast] rod draw " + attack.m_drawDurationMin + " s -> " + 2.5f + " s (bowDraw " + attack.m_bowDraw + ")"); attack.m_drawDurationMin = 2.5f; } } } internal static bool Drawing(out float pct) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) pct = 0f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !Plugin.Cast.Value || !((Character)localPlayer).IsDrawingBow()) { return false; } ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (!Tidekeeper.Baits.Rod(currentWeapon)) { return false; } pct = ((Humanoid)localPlayer).GetAttackDrawPercentage(); LastPct = pct; LastHit = Predict(localPlayer, currentWeapon.m_shared.m_attack, pct, out LastLanding); LastPredicted = (LastHit ? Flat(((Component)localPlayer).transform.position, LastLanding) : 0f); return true; } internal static float Flat(Vector3 a, Vector3 b) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Vector2 val = new Vector2(a.x - b.x, a.z - b.z); return ((Vector2)(ref val)).magnitude; } private static Flight FlightOf(GameObject proj) { Flight result = default(Flight); Projectile val = (((Object)(object)proj != (Object)null) ? proj.GetComponent<Projectile>() : null); if ((Object)(object)val != (Object)null) { result.Gravity = Fight.G<float>(PGravity, val); result.Drag = Fight.G<float>(PDrag, val); result.Radius = Fight.G<float>(PRayRadius, val); result.Ttl = Fight.G<float>(PTtl, val); result.Water = Fight.G<bool>(PCanHitWater, val); result.SpawnOnTtl = Fight.G<bool>(PSpawnOnTtl, val); } result.Mask = ((PMask != null) ? ((int)PMask.GetValue(null)) : 0); if (result.Mask == 0) { result.Mask = LayerMask.GetMask(new string[12] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle" }); } string text = (((Object)(object)proj != (Object)null) ? ((Object)proj).name : "none") + " g " + result.Gravity + " drag " + result.Drag + " ray " + result.Radius + " ttl " + result.Ttl + " water " + result.Water; if (text != _flightLogged) { _flightLogged = text; Plugin.Detail("[cast] the float's projectile: " + text + " spawnOnTtl " + result.SpawnOnTtl + " mask " + result.Mask); } return result; } internal static bool Predict(Player p, Attack a, float pct, out Vector3 landing) { //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_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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) landing = Vector3.zero; if (a == null) { return false; } if (!Launch(p, a, pct, out var pos, out var v, out var f)) { return false; } Vector3 centerPoint = ((Character)p).GetCenterPoint(); centerPoint.y = pos.y; return Fly(p, centerPoint, pos, v, f, out landing); } private static Transform Origin(Player p, string joint) { if (string.IsNullOrEmpty(joint)) { return ((Component)p).transform; } GameObject visual = ((Character)p).GetVisual(); if ((Object)(object)visual == (Object)null) { return ((Component)p).transform; } if ((Object)(object)_origin == (Object)null || (Object)(object)_originOf != (Object)(object)visual || _originJoint != joint) { _origin = Utils.FindChild(visual.transform, joint, (IterativeSearchType)0); _originOf = visual; _originJoint = joint; } if (!((Object)(object)_origin != (Object)null)) { return ((Component)p).transform; } return _origin; } internal static bool Launch(Player p, Attack a, float pct, out Vector3 pos, out Vector3 v, out Flight f) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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) ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon(); ItemData val = ((currentWeapon != null && FindAmmo != null) ? FindAmmo((Humanoid)(object)p, currentWeapon) : null); GameObject val2 = Fight.G<GameObject>(FProjectile, a); float num = Fight.G<float>(FVel, a); float num2 = Fight.G<float>(FVelMin, a); AnimationCurve val3 = Fight.G<AnimationCurve>(FVelCurve, a); Attack val4 = val?.m_shared.m_attack; GameObject val5 = ((val4 != null) ? Fight.G<GameObject>(FProjectile, val4) : null); if ((Object)(object)val5 != (Object)null) { val2 = val5; num += Fight.G<float>(FVel, val4); num2 += Fight.G<float>(FVelMin, val4); val3 = Fight.G<AnimationCurve>(FVelCurve, val4); } f = FlightOf(val2); Transform transform = ((Component)p).transform; pos = Origin(p, Fight.G<string>(FJoint, a)).position + transform.up * Fight.G<float>(FHeight, a) + transform.forward * Fight.G<float>(FRange, a) + transform.right * Fight.G<float>(FOffset, a); Vector3 val6 = AimDir((Humanoid)(object)p, pos); if (Fight.G<bool>(FUseFacing, a)) { Vector3 forward = Vector3.forward; if (Fight.G<bool>(FUseFacingY, a)) { forward.y = val6.y; } val6 = transform.TransformDirection(forward); } float num3 = Fight.G<float>(FLaunchAngle, a); if (num3 != 0f) { val6 = Quaternion.AngleAxis(num3, Vector3.Cross(Vector3.up, val6)) * val6; } float num4 = num; if (Fight.G<bool>(FBowDraw, a)) { num4 = Mathf.Lerp(num2, num, (val3 != null) ? val3.Evaluate(pct) : pct); } if (Fight.G<bool>(FRandomVel, a)) { num4 = (num2 + num4) * 0.5f; } v = val6 * num4; return (Object)(object)val2 != (Object)null; } internal static bool Fly(Player owner, Vector3 prev, Vector3 pos, Vector3 v, Flight f, out Vector3 landing) { //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_003c: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) landing = Vector3.zero; float num = ((Time.fixedDeltaTime > 0f) ? Time.fixedDeltaTime : 0.02f); float num2 = f.Ttl; bool flag = true; for (int i = 0; i < 1500; i++) { if (!flag) { prev = pos; } v += Vector3.down * (f.Gravity * num); float num3 = ((Vector3)(ref v)).sqrMagnitude * f.Drag * num; v += -((Vector3)(ref v)).normalized * num3; pos += v * num; if (f.Water && pos.y < LiquidLevel(pos, 1f, (LiquidType)10)) { landing = pos; return true; } Vector3 val = pos - prev; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > 0.0001f) { Vector3 val2 = (flag ? prev : (prev - val * 0.5f)); Vector3 val3 = val / magnitude; int num4 = ((f.Radius == 0f) ? Physics.RaycastNonAlloc(val2, val3, Hits, magnitude * 1.5f, f.Mask) : Physics.SphereCastNonAlloc(val2, f.Radius, val3, Hits, magnitude, f.Mask)); float num5 = float.MaxValue; bool flag2 = false; for (int j = 0; j < num4; j++) { Collider collider = ((RaycastHit)(ref Hits[j])).collider; if (!((Object)(object)collider == (Object)null) && !collider.isTrigger && (!((Object)(object)owner != (Object)null) || !((Component)collider).transform.IsChildOf(((Component)owner).transform))) { float distance = ((RaycastHit)(ref Hits[j])).distance; if (distance < num5) { num5 = distance; landing = ((distance != 0f) ? ((RaycastHit)(ref Hits[j])).point : val2); flag2 = true; } } } if (flag2) { return true; } } flag = false; if (num2 > 0f) { num2 -= num; if (num2 <= 0f) { landing = pos; return f.SpawnOnTtl; } } } return false; } [HarmonyPatch(typeof(FishingFloat), "TryToHook")] [HarmonyPrefix] private static void LongerHookWindow(FishingFloat __instance) { if (Plugin.Fight.Value && FNibbler.GetValue(__instance) != null) { float num = Time.time - Fight.G<float>(FNibbleTime, __instance); Character obj = Fight.GetOwner(__instance); Humanoid val = (Humanoid)(object)((obj is Humanoid) ? obj : null); object? value = FNibbler.GetValue(__instance); Fish f = (Fish)((value is Fish) ? value : null); float num2 = 1f - Parts.FishWary(Rod.FishTier(f)) + Parts.HookExtra(Parts.TierOn(((Object)(object)val != (Object)null) ? val.GetCurrentWeapon() : null, Parts.Slot.Hook)); if (num >= 0.5f && num < num2) { FNibbleTime.SetValue(__instance, Time.time - 0.4f); Plugin.Detail("[cast] hooked " + num.ToString("0.00") + " s after the nibble (the game alone allows 0.5 s)"); } } } [HarmonyPostfix] [HarmonyPatch(typeof(Projectile), "Setup")] private static void Thrown(Projectile __instance, Character owner, Vector3 velocity, ItemData item) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((owner is Player) ? owner : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer) && Tidekeeper.Baits.Rod(item)) { _thrownAt = ((Component)__instance).transform.position; _thrownTime = Time.time; Attack attack = item.m_shared.m_attack; Vector3 pos; Vector3 v; Flight f; bool flag = Launch(val, attack, LastPct, out pos, out v, out f); Vector3 centerPoint = ((Character)val).GetCenterPoint(); centerPoint.y = _thrownAt.y; bool flag2 = flag && Fly(val, centerPoint, _thrownAt, velocity, f, out _ourLanding); string[] array = new string[20] { "[cast] thrown: real ", ((Vector3)(ref velocity)).magnitude.ToString("0.0"), " m/s at ", Pitch(velocity).ToString("0"), " deg from ", ((Vector3)(ref _thrownAt)).ToString("F2"), "; ours ", ((Vector3)(ref v)).magnitude.ToString("0.0"), " m/s at ", Pitch(v).ToString("0"), " deg from ", ((Vector3)(ref pos)).ToString("F2"), " (", null, null, null, null, null, null, null }; Vector3 val2 = pos - _thrownAt; array[13] = ((Vector3)(ref val2)).magnitude.ToString("0.00"); array[14] = " m off, aim off "; array[15] = Vector3.Angle(v, velocity).ToString("0.0"); array[16] = " deg); marker said "; array[17] = (LastHit ? (Flat(((Component)val).transform.position, LastLanding).ToString("0.0") + " m") : "none"); array[18] = "; flight from the real throw lands "; array[19] = (flag2 ? (Flat(((Component)val).transform.position, _ourLanding).ToString("0.0") + " m") : "none"); Plugin.Detail(string.Concat(array)); } } private static float Pitch(Vector3 v) { //IL_0015: 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) float y = v.y; Vector2 val = new Vector2(v.x, v.z); return Mathf.Atan2(y, ((Vector2)(ref val)).magnitude) * 57.29578f; } [HarmonyPatch(typeof(FishingFloat), "Setup")] [HarmonyPostfix] private static void Cast(FishingFloat __instance, Character owner, Vector3 velocity, ItemData ammo) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0044: 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_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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)owner != (Object)(object)Player.m_localPlayer)) { FloatInfo component = ((Component)__instance).GetComponent<FloatInfo>(); if ((Object)(object)component != (Object)null) { component.Predicted = (LastHit ? LastPredicted : (-1f)); } Player val = (Player)owner; Vector3 position = ((Component)__instance).transform.position; Plugin.Detail("[cast] float born at " + ((Vector3)(ref position)).ToString("F2") + ", " + Flat(((Component)val).transform.position, position).ToString("0.0") + " m away" + ((Time.time - _thrownTime < 10f) ? (", " + (Time.time - _thrownTime).ToString("0.00") + " s after the throw; our flight of that throw ended " + Flat(position, _ourLanding).ToString("0.00") + " m from it") : "") + "; the marker was " + (LastHit ? (Flat(position, LastLanding).ToString("0.00") + " m from it") : "not shown")); Plugin.Detail("[cast] speed " + ((Vector3)(ref velocity)).magnitude.ToString("0.0") + " m/s, draw " + (LastPct * 100f).ToString("0") + "%, predicted landing " + (LastHit ? (LastPredicted.ToString("0.0") + " m") : "none") + ", bait " + ((ammo != null) ? ((Object)ammo.m_dropPrefab).name : "?") + ", baits in the bag " + Baits(val)); } } [HarmonyPrefix] [HarmonyPatch(typeof(FishingFloat), "ReturnBait")] private static void BeforeReturn(FishingFloat __instance, out string __state) { Character obj = Fight.GetOwner(__instance); Player val = (Player)(object)((obj is Player) ? obj : null); __state = (((Object)(object)val != (Object)null) ? Baits(val) : ""); } [HarmonyPostfix] [HarmonyPatch(typeof(FishingFloat), "ReturnBait")] private static void AfterReturn(FishingFloat __instance, string __state) { Character obj = Fight.GetOwner(__instance); Player val = (Player)(object)((obj is Player) ? obj : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer)) { Plugin.Detail("[cast] bait returned (" + GetBait(__instance) + "): bag " + __state + " -> " + Baits(val)); } } [HarmonyPatch(typeof(FishingFloat), "RPC_Nibble")] [HarmonyPostfix] private static void Nibble(FishingFloat __instance, ZDOID fishID, bool correctBait) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) ZNetView val = Fight.G<ZNetView>(FNview, __instance); if (!((Object)(object)val == (Object)null) && val.IsOwner()) { GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.FindInstance(fishID) : null); Plugin.Detail("[cast] nibble by " + (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "?") + (correctBait ? " (can be hooked)" : " (wrong bait)")); } } private static string Baits(Player p) { string text = ""; foreach (ItemData allItem in ((Humanoid)p).GetInventory().GetAllItems()) { if ((Object)(object)allItem.m_dropPrefab != (Object)null && ((Object)allItem.m_dropPrefab).name.StartsWith("FishingBait")) { object obj = text; text = string.Concat(obj, (text.Length > 0) ? ", " : "", ((Object)allItem.m_dropPrefab).name, " x", allItem.m_stack); } } if (text.Length <= 0) { return "none"; } return text; } } [HarmonyPatch] internal static class Dishes { internal class Dish { public string Id; public string Title; public string Biome; public string Base; public string Bonus; public string[] Fish; public string[] Recipe; public GameObject Prefab; public Recipe RecipeObj; public SE_Stats Effect; } internal const float HelmBonus = 0.33f; internal const float MineStamina = 0.8f; internal const float WispRange = 1.5f; internal static readonly Dish[] All = new Dish[11] { new Dish { Id = "TK_PerchSkewer", Title = "Perch Skewer", Biome = "Meadows", Base = "FishCooked", Fish = new string[1] { "Fish1" }, Recipe = new string[3] { "Fish1:1", "Raspberry:3", "Honey:1" }, Bonus = "Stamina comes back 50% faster." }, new Dish { Id = "TK_TrollfishStew", Title = "Trollfish Mushroom Stew", Biome = "Black Forest", Base = "CarrotSoup", Fish = new string[1] { "Fish5" }, Recipe = new string[3] { "Fish5:1", "Mushroom:2", "Carrot:1" }, Bonus = "Mining and chopping use 20% less stamina." }, new Dish { Id = "TK_SmokedHerring", Title = "Smoked Herring", Biome = "Swamp", Base = "TurnipStew", Fish = new string[1] { "Fish6" }, Recipe = new string[3] { "Fish6:1", "Turnip:2", "Thistle:1" }, Bonus = "Resistant to poison." }, new Dish { Id = "TK_TetraBroth", Title = "Tetra Broth", Biome = "Mountains", Base = "OnionSoup", Fish = new string[1] { "Fish4_cave" }, Recipe = new string[3] { "Fish4_cave:1", "Carrot:2", "FreezeGland:1" }, Bonus = "Resistant to frost: the cold won't freeze you." }, new Dish { Id = "TK_GrouperFlatbread", Title = "Grouper Flatbread", Biome = "Plains", Base = "FishWraps", Fish = new string[1] { "Fish7" }, Recipe = new string[3] { "Fish7:1", "BarleyFlour:2", "Cloudberry:1" }, Bonus = "Running and jumping use 25% less stamina." }, new Dish { Id = "TK_SailorsChowder", Title = "Sailor's Chowder", Biome = "Ocean", Base = "SerpentStew", Fish = new string[1] { "Fish3" }, Recipe = new string[3] { "Fish3:1", "Chitin:1", "Carrot:2" }, Bonus = "At the helm, your ship sails 33% faster. Fishing skill grows 25% faster." }, new Dish { Id = "TK_AnglerFillet", Title = "Angler Fillet", Biome = "Mistlands", Base = "FishAndBread", Fish = new string[1] { "Fish9" }, Recipe = new string[3] { "Fish9:1", "MushroomMagecap:1", "MushroomJotunPuffs:2" }, Bonus = "Your wisp clears the mist 50% farther." }, new Dish { Id = "TK_EmberMagmafish", Title = "Ember-grilled Magmafish", Biome = "Ashlands", Base = "FierySvinstew", Fish = new string[1] { "Fish11" }, Recipe = new string[3] { "Fish11:1", "Vineberry:2", "Fiddleheadfern:1" }, Bonus = "Resistant to fire." }, new Dish { Id = "TK_PikeRoast", Title = "Pike Herb Roast", Biome = "Meadows", Base = "FishCooked", Fish = new string[1] { "Fish2" }, Recipe = new string[3] { "Fish2:1", "Dandelion:2", "Mushroom:1" }, Bonus = "Health comes back twice as fast." }, new Dish { Id = "TK_CoralCodPot", Title = "Coral Cod Pot", Biome = "Ocean", Base = "SerpentStew", Fish = new string[1] { "Fish8" }, Recipe = new string[3] { "Fish8:1", "SerpentMeat:1", "Turnip:1" }, Bonus = "Swimming uses 50% less stamina, and you swim 50% faster." }, new Dish { Id = "TK_PufferGlaze", Title = "Puffer Sap Glaze", Biome = "Mistlands", Base = "MisthareSupreme", Fish = new string[1] { "Fish12" }, Recipe = new string[3] { "Fish12:1", "Sap:1", "RoyalJelly:1" }, Bonus = "Falls hurt 50% less, and you jump 60% higher." } }; private static GameObject _holder; private static string _opened; private static float _nextCheck; private static readonly FieldInfo FAttackChar = AccessTools.Field(typeof(Attack), "m_character"); private static readonly FieldInfo FAttackWeapon = AccessTools.Field(typeof(Attack), "m_weapon"); private static float _lastHelmLog; private static readonly Dictionary<int, float> WispBase = new Dictionary<int, float>(); private static float _nextWisp; internal static Dish ForFish(string fish) { Dish[] all = All; foreach (Dish dish in all) { if (Array.IndexOf(dish.Fish, fish) >= 0) { return dish; } } return null; } private static Dish Find(string id) { Dish[] all = All; foreach (Dish dish in all) { if (dish.Id == id) { return dish; } } return null; } private static void BuildAll(Func<string, GameObject> find) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown Dish[] all = All; foreach (Dish dish in all) { if ((Object)(object)dish.Prefab != (Object)null) { continue; } GameObject val = find(dish.Base) ?? find("FishCooked"); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)_holder == (Object)null) { _holder = new GameObject("Tidekeeper_Dishes"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); } GameObject val2 = Object.Instantiate<GameObject>(val, _holder.transform, false); ((Object)val2).name = dish.Id; ItemDrop component = val2.GetComponent<ItemDrop>(); component.m_itemData.m_dropPrefab = val2; SharedData shared = component.m_itemData.m_shared; SharedData val3 = (SharedData)AccessTools.Method(typeof(object), "MemberwiseClone", (Type[])null, (Type[])null).Invoke(shared, null); component.m_itemData.m_shared = val3; val3.m_name = dish.Title; val3.m_description = "A " + dish.Biome + " dish of fish. " + dish.Bonus; val3.m_consumeStatusEffect = (StatusEffect)(object)Effect(dish, val3); dish.Prefab = val2; Plugin.Detail("[dishes] " + dish.Id + " made from " + ((Object)val).name + ": health " + val3.m_food + ", stamina " + val3.m_foodStamina + ", " + val3.m_foodBurnTime + " s"); } } } private static SE_Stats Effect(Dish d, SharedData food) { //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "SE_" + d.Id; ((StatusEffect)val).m_name = d.Title; ((StatusEffect)val).m_tooltip = d.Bonus; ((StatusEffect)val).m_icon = ((food.m_icons != null && food.m_icons.Length > 0) ? food.m_icons[0] : null); ((StatusEffect)val).m_ttl = ((food.m_foodBurnTime > 0f) ? food.m_foodBurnTime : 1200f); val.m_mods = new List<DamageModPair>(); switch (d.Id) { case "TK_PerchSkewer": val.m_staminaRegenMultiplier = 1.5f; break; case "TK_PikeRoast": val.m_healthRegenMultiplier = 2f; break; case "TK_SmokedHerring": val.m_mods.Add(new DamageModPair { m_type = (DamageType)256, m_modifier = (DamageModifier)1 }); break; case "TK_TetraBroth": val.m_mods.Add(new DamageModPair { m_type = (DamageType)64, m_modifier = (DamageModifier)1 }); break; case "TK_GrouperFlatbread": val.m_runStaminaDrainModifier = -0.25f; val.m_jumpStaminaUseModifier = -0.25f; break; case "TK_SailorsChowder": val.m_raiseSkill = (SkillType)104; val.m_raiseSkillModifier = 0.25f; break; case "TK_CoralCodPot": val.m_swimStaminaUseModifier = -0.5f; val.m_swimSpeedModifier = 0.5f; break; case "TK_PufferGlaze": val.m_fallDamageModifier = -0.5f; val.m_jumpModifier = new Vector3(0f, 0.6f, 0f); break; case "TK_EmberMagmafish": val.m_mods.Add(new DamageModPair { m_type = (DamageType)32, m_modifier = (DamageModifier)1 }); break; } d.Effect = val; return val; } [HarmonyPostfix] [HarmonyPatch(typeof(ZNetScene), "Awake")] private static void SceneAwake(ZNetScene __instance) { if (!Plugin.Dishes.Value) { return; } BuildAll((string n) => __instance.m_prefabs.Find((GameObject g) => (Object)(object)g != (Object)null && ((Object)g).name == n)); FieldInfo fieldInfo = AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs"); Dictionary<int, GameObject> dictionary = ((fieldInfo != null) ? (fieldInfo.GetValue(__instance) as Dictionary<int, GameObject>) : null); Dish[] all = All; foreach (Dish dish in all) { if (!((Object)(object)dish.Prefab == (Object)null)) { if (!__instance.m_prefabs.Contains(dish.Prefab)) { __instance.m_prefabs.Add(dish.Prefab); } if (dictionary != null) { dictionary[StringExtensionMethods.GetStableHashCode(((Object)dish.Prefab).name)] = dish.Prefab; } } } Register(ObjectDB.instance); } [HarmonyPatch(typeof(ObjectDB), "Awake")] [HarmonyPriority(200)] [HarmonyPostfix] private static void DbAwake(ObjectDB __instance) { Register(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] private static void DbCopy(ObjectDB __instance) { Register(__instance); } private static void Register(ObjectDB db) { //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown if (!Plugin.Dishes.Value || (Object)(object)db == (Object)null || db.m_items == null || db.m_items.Count == 0 || (Object)(object)ZNetScene.instance == (Object)null) { return; } BuildAll((string n) => db.m_items.Find((GameObject g) => (Object)(object)g != (Object)null && ((Object)g).name == n)); bool flag = false; Dish[] all = All; foreach (Dish dish in all) { if (!((Object)(object)dish.Prefab == (Object)null)) { if (!db.m_items.Contains(dish.Prefab)) { db.m_items.Add(dish.Prefab); flag = true; } if ((Object)(object)dish.Effect != (Object)null && !db.m_StatusEffects.Contains((StatusEffect)(object)dish.Effect)) { db.m_StatusEffects.Add((StatusEffect)(object)dish.Effect); } } } if (flag) { MethodInfo methodInfo = AccessTools.Method(typeof(ObjectDB), "UpdateRegisters", (Type[])null, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(db, null); } } GameObject prefab = ZNetScene.instance.GetPrefab("piece_cauldron"); CraftingStation val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<CraftingStation>() : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Dishes: no cauldron found, the dishes have no recipe."); return; } Dish[] all2 = All; foreach (Dish dish2 in all2) { if ((Object)(object)dish2.Prefab == (Object)null) { continue; } List<Requirement> list = new List<Requirement>(); bool flag2 = true; string[] recipe = dish2.Recipe; foreach (string text in recipe) { string[] array = text.Split(':'); GameObject itemPrefab = db.GetItemPrefab(array[0]); if ((Object)(object)itemPrefab == (Object)null) { Plugin.Log.LogWarning((object)("Dishes: no item '" + array[0] + "' for the " + dish2.Title + ".")); flag2 = false; } else { Requirement val2 = new Requirement(); val2.m_resItem = itemPrefab.GetComponent<ItemDrop>(); val2.m_amount = int.Parse(array[1]); list.Add(val2); } } if (flag2) { ItemDrop drop = dish2.Prefab.GetComponent<ItemDrop>(); Recipe val3 = db.m_recipes.Find((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item == (Object)(object)drop); if ((Object)(object)val3 == (Object)null) { val3 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val3).name = "Recipe_" + dish2.Id; db.m_recipes.Add(val3); } val3.m_item = drop; val3.m_amount = 1; val3.m_enabled = false; val3.m_craftingStation = val; val3.m_minStationLevel = 1; val3.m_resources = list.ToArray(); dish2.RecipeObj = val3; } } _opened = null; } internal static bool Open(Dish d, Dictionary<string, Journal.Entry> log) { string[] fish = d.Fish; foreach (string key in fish) { if (log.TryGetValue(key, out var value) && value.Caught) { return true; } } return false; } internal static void Locks(bool now) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !Plugin.Dishes.Value || (!now && Time.time < _nextCheck)) { return; } _nextCheck = Time.time + 3f; Dictionary<string, Journal.Entry> log = Journal.All(localPlayer); string text = ""; Dish[] all = All; foreach (Dish dish in all) { text += (((Object)(object)dish.RecipeObj != (Object)null && Open(dish, log)) ? "1" : "0"); } if (text == _opened) { return; } for (int j = 0; j < All.Length; j++) { Dish dish2 = All[j]; if (!((Object)(object)dish2.RecipeObj == (Object)null)) { bool flag = text[j] == '1'; if (flag && !dish2.RecipeObj.m_enabled && _opened != null) { Plugin.Log.LogInfo((object)("[dishes] your log opened the " + dish2.Title)); ((Character)localPlayer).Message((MessageType)2, "New dish: " + dish2.Title, 0, (Sprite)null, false); } dish2.RecipeObj.m_enabled = flag; } } Plugin.Detail("[dishes] open: " + text); _opened = text; } private static bool Has(Character c, Dish d) { if ((Object)(object)c != (Object)null && d != null && (Object)(object)d.Effect != (Object)null && c.GetSEMan() != null) { return c.GetSEMan().HaveStatusEffect(((StatusEffect)d.Effect).NameHash()); } return false; } [HarmonyPatch(typeof(Attack), "GetAttackStamina")] [HarmonyPostfix] private static void MineStaminaCut(Attack __instance, ref float __result) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Invalid comparison between Unknown and I4 //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 if (__result <= 0f || FAttackChar == null || FAttackWeapon == null) { return; } object? value = FAttackChar.GetValue(__instance); Character val = (Character)((value is Character) ? value : null); if (!(val is Player)) { return; } object? value2 = FAttackWeapon.GetValue(__instance); ItemData val2 = (ItemData)((value2 is ItemData) ? value2 : null); if (val2 != null) { SkillType skillType = val2.m_shared.m_skillType; if (((int)skillType == 12 || (int)skillType == 13) && Has(val, Find("TK_TrollfishStew"))) { __result *= 0.8f; } } } [HarmonyPostfix] [HarmonyPatch(typeof(Ship), "GetSailForce")] private static void HelmSpeed(Ship __instance, ref Vector3 __result) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)localPlayer.GetControlledShip() != (Object)(object)__instance) && Has((Character)(object)localPlayer, Find("TK_SailorsChowder"))) { __result *= 1.33f; if (Plugin.DetailedLog.Value && Time.time - _lastHelmLog > 10f) { _lastHelmLog = Time.time; Plugin.Detail("[dishes] Sailor's Chowder: sail force +" + Mathf.RoundToInt(33f) + "%"); } } } internal static void Wisp() { if (Time.time < _nextWisp) { return; } _nextWisp = Time.time + 0.5f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } bool flag = Plugin.Dishes.Value && Has((Character)(object)localPlayer, Find("TK_AnglerFillet")); Demister[] componentsInChildren = ((Component)localPlayer).GetComponentsInChildren<Demister>(); foreach (Demister val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.m_forceField == (Object)null)) { int instanceID = ((Object)val).GetInstanceID(); if (!WispBase.TryGetValue(instanceID, out var value)) { value = val.m_forceField.endRange; WispBase[instanceID] = value; } float num = (flag ? (value * 1.5f) : value); if (Mathf.Abs(val.m_forceField.endRange - num) > 0.01f) { val.m_forceField.endRange = num; Plugin.Detail("[dishes] wisp range " + num); } } } } } internal class FightState : MonoBehaviour { public Fish Fish; public float Line; public float Tension; public float OverTime; public float SlackTime; public int Phase; public int Act; public float ActUntil; public float NextAct; public float NextJolt; public float TiredUntil; public bool WasSurging; public int Surges; public bool Common; public int Quality; public float LenCm; public float Kg; public bool FirstCatch; public bool NewRecord; public float BannerAt = -10f; public int Tier; public int RodTier; public float RodStrength = 1f; public float Reel = 1f; public float Grip = 1f; public float SkillTimer; public float Started; public float NextLog; public bool Reeling; public bool LoggedFirstReel; public float NextShake; public bool WasSurgingShake; public float FirstReelAt = -10f; public float Progress; public float StartLine; public float SnagTime; public float SurgeEndedAt = -10f; public float SurgeStartedAt = -10f; public float Wear; public int WearStep; public Color LineColorA; public Color LineColorB; public bool LineColorSaved; public bool LineTinted; public bool LineShaderSwapped; public bool LineWidthSaved; public float LineWidth; public bool Freeing; public float FreeUntil; public bool FreeWasKinematic; public float LastNow; public Vector3 LastWater; public bool Hanging; public float HangStart; public Vector3 HangFrom; public Quaternion HangRot; public bool WasKinematic; } [HarmonyPatch] internal static class Fight { private const float StartLineCommon = 6f; private const float StartLine = 8f; private const float StartLinePerLevel = 1.5f; internal const float HangDistance = 2f; internal const float HangSeconds = 15f; internal const float ThrashAfter = 8f; private const float LiftSeconds = 0.7f; private const float BreakSeconds = 0.9f; private const float SlackSeconds = 4f; private const float SlackTension = 0.08f; private const float SurgeHold = 0.3f; private const float TiredFloor = 0.25f; private const float SurgeReaction = 0.5f; private const float TiredSeconds = 3f; private const float ReelSpeed = 1.5f; private const float TiredReelBoost = 2f; internal const float GreenFrom = 0.15f; internal const float RedFrom = 0.75f; private const int CommonSurges = 3; private const float DriftCalm = 0.5f; private const float DriftTired = 0.15f; private const float ShakeEvery = 0.2f; private const float RushSpeed = 2.2f; private const float PayoutSpeed = 1.6f; private const float LineAhead = 1f; private const float GainCalmReel = 0.3f; private const float GainSurgeReel = 0.9f; private const float GainTiredReel = 0.12f; private const float LossCalmFree = 0.7f; private const float LossSurgeFree = 0.3f; private const float LossTiredFree = 0.8f; private const float ShakeBoost = 1.6f; private const float CatchSeconds = 10f; private const float CatchSecondsCommon = 7f; private const float OverPerTier = 0.6f; private const float WearSurge = 3.3f; private const float WearRedMin = 1.2f; private const float WearRedMax = 4.5f; private const float WearTop = 6.5f; private const float WearGrace = 1.5f; internal static FightState Shown; private static float _noUseUntil; private static float _noHideUntil; private static readonly FieldInfo FNview = AccessTools.Field(typeof(FishingFloat), "m_nview"); private static readonly FieldInfo FBody = AccessTools.Field(typeof(FishingFloat), "m_body"); private static readonly FieldInfo FMoveForce = AccessTools.Field(typeof(FishingFloat), "m_moveForce"); private static readonly FieldInfo FMaxDistance = AccessTools.Field(typeof(FishingFloat), "m_maxDistance"); private static readonly FieldInfo FSkillHookedMul = AccessTools.Field(typeof(FishingFloat), "m_fishingSkillImproveHookedMultiplier"); private static readonly FieldInfo FMaxSlack = AccessTools.Field(typeof(FishingFloat), "m_maxLineSlack"); internal static readonly FieldInfo FLineLength = AccessTools.Field(typeof(FishingFloat), "m_lineLength"); private static readonly FieldInfo FRodLine = AccessTools.Field(typeof(FishingFloat), "m_rodLine"); private static readonly FieldInfo FNibbleFx = AccessTools.Field(typeof(FishingFloat), "m_nibbleEffect"); private static readonly FieldInfo FBreakFx = AccessTools.Field(typeof(FishingFloat), "m_lineBreakEffect"); private static readonly FieldInfo FNextEscape = AccessTools.Field(typeof(Fish), "m_nextEscape"); private static readonly FieldInfo FEscapeTime = AccessTools.Field(typeof(Fish), "m_escapeTime"); private static readonly FieldInfo FFishTime = AccessTools.Field(typeof(Fish), "s_time"); private static readonly FieldInfo FFishBody = AccessTools.Field(typeof(Fish), "m_body"); private static readonly FieldInfo FFishNview = AccessTools.Field(typeof(Fish), "m_nview"); internal static readonly Func<FishingFloat, Character> GetOwner = AccessTools.MethodDelegate<Func<FishingFloat, Character>>(AccessTools.Method(typeof(FishingFloat), "GetOwner", (Type[])null, (Type[])null), (object)null, true); internal static readonly Func<FishingFloat, Character, Transform> GetRodTop = AccessTools.MethodDelegate<Func<FishingFloat, Character, Transform>>(AccessTools.Method(typeof(FishingFloat), "GetRodTop", (Type[])null, (Type[])null), (object)null, true); internal static readonly Func<FishingFloat, Fish> GetCatch = AccessTools.MethodDelegate<Func<FishingFloat, Fish>>(AccessTools.Method(typeof(FishingFloat), "GetCatch", (Type[])null, (Type[])null), (object)null, true); private static readonly Action<FishingFloat, Fish> SetCatch = AccessTools.MethodDelegate<Action<FishingFloat, Fish>>(AccessTools.Method(typeof(FishingFloat), "SetCatch", (Type[])null, (Type[])null), (object)null, true); internal static readonly Action<FishingFloat, string, bool> Message = AccessTools.MethodDelegate<Action<FishingFloat, string, bool>>(AccessTools.Method(typeof(FishingFloat), "Message", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<Fish, Character, string> Catch = AccessTools.MethodDelegate<Func<Fish, Character, string>>(AccessTools.Method(typeof(FishingFloat), "Catch", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<Fish, bool> IsEscaping = AccessTools.MethodDelegate<Func<Fish, bool>>(AccessTools.Method(typeof(Fish), "IsEscaping", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<Fish, Vector3, float> PointDepth = AccessTools.MethodDelegate<Func<Fish, Vector3, float>>(AccessTools.Method(typeof(Fish), "GetPointDepth", (Type[])null, (Type[])null), (object)null, true); private static readonly Action<Fish, FishingFloat> OnHooked = AccessTools.MethodDelegate<Action<Fish, FishingFloat>>(AccessTools.Method(typeof(Fish), "OnHooked", (Type[])null, (Type[])null), (object)null, true); internal static float ShakeUntil; private static readonly FieldInfo FLineRenderer = AccessTools.Field(typeof(LineConnect), "m_lineRenderer"); private static readonly Color Yellow = new Color(1f, 0.85f, 0.2f); private static readonly Color Red = new Color(0.95f, 0.15f, 0.1f); private static readonly string[] TintProps = new string[4] { "_Color", "_TintColor", "_BaseColor", "_MainColor" }; private static readonly int SolidMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" }); private static int _jumpsLogged; private static readonly Func<Character, FishingFloat> FloatOf = AccessTools.MethodDelegate<Func<Character, FishingFloat>>(AccessTools.Method(typeof(FishingFloat), "FindFloat", new Type[1] { typeof(Character) }, (Type[])null), (object)null, true); internal static bool Active { get { if ((Object)(object)Shown != (Object)null) { return (Object)(object)Shown.Fish != (Object)null; } return false; } } internal static bool HangingNow { get { if (Active) { return Shown.Hanging; } return false; } } internal static T G<T>(FieldInfo f, object o) { return (T)f.GetValue(o); } [HarmonyPatch(typeof(FishingFloat), "FixedUpdate")] [HarmonyPrefix] private static bool Update(FishingFloat __instance) { ZNetView val = G<ZNetView>(FNview, __instance); if ((Object)(object)val == (Object)null || !val.IsValid() || !val.IsOwner()) { return true; } Fish val2 = GetCatch(__instance); FightState fightState = ((Component)__instance).GetComponent<FightState>(); if ((Object)(object)val2 == (Object)null || !Plugin.Fight.Value) { if ((Object)(object)fightState != (Object)null) { End(fightState, val2); } return CastTweaks.EmptyLine(__instance); } Character val3 = GetOwner(__instance); if ((Object)(object)val3 == (Object)null) { return true; } Transform val4 = GetRodTop(__instance, val3); if ((Object)(object)val4 == (Object)null) { return true; } if (val3.InAttack() || val3.IsDrawingBow()) { if ((Object)(object)fightState != (Object)null) { Plugin.Detail("[fight] cancelled by an attack"); End(fightState, val2); } return true; } try { if ((Object)(object)fightState == (Object)null || (Object)(object)fightState.Fish != (Object)(object)val2) { fightState = Begin(__instance, val2, val3, val4); } if (fightState.Hanging) { Hang(__instance, val, fightState, val2, val3, val4); } else { Step(__instance, val, fightState, val2, val3, val4, Time.fixedDeltaTime); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[fight] error, the game's own fishing takes over: " + ex)); if ((Object)(object)fightState != (Object)null) { End(fightState, val2); } return true; } return false; } private static float Flat(Character owner, Vector3 p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)owner).transform.position; Vector2 val = new Vector2(p.x - position.x, p.z - position.z); return ((Vector2)(ref val)).magnitude; } private static FightState Begin(FishingFloat ff, Fish fish, Character owner, Transform rodTop) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) FightState fightState = ((Component)ff).GetComponent<FightState>() ?? ((Component)ff).gameObject.AddComponent<FightState>(); fightState.Fish = fish; ItemDrop component = ((Component)fish).GetComponent<ItemDrop>(); fightState.Quality = ((!((Object)(object)component != (Object)null)) ? 1 : Mathf.Max(1, component.m_itemData.m_quality)); fightState.Common = TakesBasicBait(fish); ItemData val = ((owner is Humanoid) ? ((Humanoid)owner).GetCurrentWeapon() : null); fightState.Tier = Rod.FishTier(fish); fightState.RodTier = Rod.Tier(val); fightState.RodStrength = Rod.Strength(val); fightState.Reel = Parts.ReelBonus(Parts.TierOn(val, Parts.Slot.Reel)); fightState.Grip = Parts.GripBonus(Parts.TierOn(val, Parts.Slot.Grip)); float num = Flat(owner, ((Component)fish).transform.position); float num2 = (fightState.Common ? 6f : 8f) + (float)(fightState.Quality - 1) * 1.5f; fightState.Line = (fightState.StartLine = Mathf.Max(num, num2)); fightState.Progress = 0f; fightState.Tension = 0.25f; fightState.OverTime = (fightState.SlackTime = 0f); fightState.Phase = 0; fightState.Surges = 0; fightState.WasSurging = false; fightState.TiredUntil = 0f; fightState.Hanging = false; fightState.LoggedFirstReel = false; fightState.Act = 0; fightState.ActUntil = 0f; fightState.NextAct = Time.time + Random.Range(2.5f, 4f); fightState.Started = Time.time; fightState.LastWater = ((Component)fish).transform.position; Plugin.Detail("[fight] hooked " + ((Object)fish).name + " level " + fightState.Quality + (fightState.Common ? " (common)" : "") + ", tier " + fightState.Tier + " on a rod for tier " + fightState.RodTier + " (line " + fightState.RodStrength + ", reel " + fightState.Reel + ", grip " + fightState.Grip + ")" + ((fightState.Tier > fightState.RodTier) ? ": too strong for this rod" : "") + " at " + num.ToString("0.0") + " m, fight line starts at " + fightState.Line.ToString("0.0") + " m, skill " + owner.GetSkillFactor((SkillType)104).ToString("0.00")); return fightState; } private static void End(FightState st, Fish fish) { if ((Object)(object)fish == (Object)null) { fish = st.Fish; } if ((Object)(object)fish != (Object)null) { Rigidbody val = G<Rigidbody>(FFishBody, fish); if (st.Hanging && (Object)(object)val != (Object)null) { val.isKinematic = st.WasKinematic; } if (st.Freeing && (Object)(object)val != (Object)null) { val.isKinematic = st.FreeWasKinematic; } Calm(fish); } if ((Object)(object)Shown == (Object)(object)st) { Shown = null; } Object.Destroy((Object)(object)st); } private static void Calm(Fish fish) { if ((Object)(object)fish == (Object)null) { return; } try { OnHooked(fish, null); FEscapeTime.SetValue(fish, 0f); FNextEscape.SetValue(fish, G<float>(FFishTime, null) + 5f); ZNetView val = G<ZNetView>(FFishNview, fish); if ((Object)(object)val != (Object)null && val.IsValid() && val.IsOwner()) { val.GetZDO().Set(ZDOVars.s_escape, 0, false); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[fight] could not calm the fish: " + ex.Message)); } } private static bool TakesBasicBait(Fish fish) { if (fish.m_baits == null) { return false; } foreach (BaitSetting bait in fish.m_baits) { if ((Object)(object)bait.m_bait != (Object)null && ((Object)bait.m_bait).name == "FishingBait") { return true; } } return false; } private static void Step(FishingFloat ff, ZNetView nv, FightState st, Fish fish, Character owner, Transform rodTop, float dt) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) float skillFactor = owner.GetSkillFactor((SkillType)104); bool flag = IsEscaping(fish); if (flag && !st.WasSurging) { st.Surges++; EffectList val = G<EffectList>(FNibbleFx, ff); if (val != null) { val.Create(((Component)ff).transform.position, Quaternion.identity, ((Component)ff).transform, 1f, -1, ZDOID.None); } st.SurgeStartedAt = Time.time; Plugin.Detail("[fight] surge " + st.Surges + " (tension " + Pct(st.Tension) + ", line " + st.Line.ToString("0.0") + " m)"); } if (!flag && st.WasSurging) { st.TiredUntil = Time.time + 3f; if (st.Common && st.Surges >= 3) { FNextEscape.SetValue(fish, float.MaxValue); } Plugin.Detail("[fight] tired for " + 3f + " s"); } st.WasSurging = flag; st.Phase = (flag ? 1 : ((Time.time < st.TiredUntil) ? 2 : 0)); if (flag && !st.WasSurgingShake) { Shake(owner, 1.2f); Sounds.Thrash(fish, 1f); } st.WasSurgingShake = flag; if (flag) { st.ActUntil = 0f; } if (st.Phase == 0 && Time.time >= st.NextAct) { float value = Random.value; float num; if ((!st.Common || st.Surges < 3) && value < 0.3f) { FNextEscape.SetValue(fish, G<float>(FFishTime, null)); num = 3f; Plugin.Detail("[fight] move: surge"); } else { st.Act = ((value < 0.65f) ? 3 : 4); num = ((st.Act == 3) ? Random.Range(1.2f, 2.2f) : Random.Range(1.5f, 2.5f)); st.ActUntil = Time.time + num; st.NextJolt = Time.time; Shake(owner, (st.Act == 3) ? 0.8f : 0.5f); Sounds.Thrash(fish, 1f); EffectList val2 = G<EffectList>(FNibbleFx, ff); if (val2 != null) { val2.Create(((Component)ff).transform.position, Quaternion.identity, ((Component)ff).transform, 1f, -1, ZDOID.None); } Plugin.Detail("[fight] move: " + ((st.Act == 3) ? "head shake" : "rush at you") + " for " + num.ToString("0.0") + " s (tension " + Pct