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 VargheimFishing v1.1.0
VargheimFishing.dll
Decompiled 4 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; using VargheimProfessions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VargheimFishing { [BepInPlugin("digi.vargheim.fishing", "VargheimFishing", "1.1.0")] [BepInDependency("digi.vargheim.professions", "0.6.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(FishingFloat), "Setup")] [HarmonyPostfix] private static void Setup(FishingFloat __instance, Character owner) { try { if (!((Object)(object)owner == (Object)null) && !((Object)(object)owner != (Object)(object)Player.m_localPlayer) && Api.Active) { int num = Level(); if (num >= LineLevel.Value) { float num2 = 1f - Mathf.Clamp01(LineSaving.Value); __instance.m_pullStaminaUse *= num2; __instance.m_hookedStaminaPerSec *= num2; __instance.m_hookedStaminaPerSecMaxSkill *= num2; } if (num >= BoatLevel.Value) { float num3 = 1f + Mathf.Max(0f, BoatBonus.Value); __instance.m_maxDistance *= num3; __instance.m_breakDistance *= num3; __instance.m_range *= num3; } } } catch (Exception ex) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("float setup: " + ex.Message)); } } [HarmonyPatch(typeof(Fish), "Pickup")] [HarmonyPrefix] private static void Pickup_Pre(Fish __instance, Humanoid character, ref bool __state) { __state = false; try { if (!((Object)(object)character == (Object)null) && !((Object)(object)character != (Object)(object)Player.m_localPlayer) && Api.Active && !((Object)(object)ItemOf(__instance) == (Object)null)) { int num = Level(); ItemData itemData = ItemOf(__instance).m_itemData; if (num >= BigLevel.Value && itemData != null && itemData.m_shared != null && itemData.m_quality < itemData.m_shared.m_maxQuality && Random.value < BigChance.Value) { itemData.m_quality++; Api.Note("Big catch!"); } __state = true; } } catch { } } [HarmonyPatch(typeof(Fish), "Pickup")] [HarmonyPostfix] private static void Pickup_Post(Fish __instance, Humanoid character, bool __result, bool __state) { try { if (!__result || !__state || (Object)(object)ItemOf(__instance) == (Object)null || ItemOf(__instance).m_itemData == null) { return; } int num = Level(); float num2 = ((num >= MasterLevel.Value) ? MasterDoubleChance.Value : ((num >= DoubleLevel.Value) ? DoubleChance.Value : 0f)); if (!(num2 <= 0f) && !(Random.value >= num2)) { ItemData val = ItemOf(__instance).m_itemData.Clone(); val.m_stack = 1; if (character.GetInventory().AddItem(val)) { Api.Note("Double catch: a second " + Localization.instance.Localize(val.m_shared.m_name) + "."); } } } catch (Exception ex) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("double catch: " + ex.Message)); } } } public const string Guid = "digi.vargheim.fishing"; public const string Version = "1.1.0"; private const string Prof = "Fishing"; internal static ConfigEntry<int> SteadyLevel; internal static ConfigEntry<int> DoubleLevel; internal static ConfigEntry<int> LineLevel; internal static ConfigEntry<int> BigLevel; internal static ConfigEntry<int> SenseLevel; internal static ConfigEntry<int> BoatLevel; internal static ConfigEntry<int> MasterLevel; internal static ConfigEntry<float> DoubleChance; internal static ConfigEntry<float> LineSaving; internal static ConfigEntry<float> BigChance; internal static ConfigEntry<float> SenseRange; internal static ConfigEntry<float> BoatBonus; internal static ConfigEntry<float> MasterDoubleChance; internal static ConfigEntry<string> SpeedCurve; internal static ConfigEntry<string> BarCurve; internal static ConfigEntry<string> ThrashCurve; internal static Plugin Instance; private static readonly FieldInfo s_fishItem = AccessTools.Field(typeof(Fish), "m_itemDrop"); private static readonly List<PinData> s_sensePins = new List<PinData>(); private static float s_senseUntil; internal static void Log(string m) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)m); } internal static void Warn(string m) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)m); } internal static ItemDrop ItemOf(Fish f) { if (!((Object)(object)f != (Object)null)) { return null; } object? value = s_fishItem.GetValue(f); return (ItemDrop)((value is ItemDrop) ? value : null); } private void Awake() { //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Expected O, but got Unknown //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Expected O, but got Unknown //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Expected O, but got Unknown //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Expected O, but got Unknown //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Expected O, but got Unknown Instance = this; SteadyLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "SteadyHandsLevel", 10, "Steady hands: from this level the Hooked fish moves slower and the catch bar grows with your level (see the curves)."); SpeedCurve = ((BaseUnityPlugin)this).Config.Bind<string>("Perks", "FishSpeedByLevel", "0:1.0, 10:0.9, 30:0.75, 50:0.6, 75:0.45, 100:0.4", "Hooked fish speed multiplier by Angler level (level:multiplier, straight lines between). Everyone else uses the level-0 value."); ThrashCurve = ((BaseUnityPlugin)this).Config.Bind<string>("Perks", "ThrashByLevel", "0:1.0, 30:0.7, 50:0.5, 75:0.3, 100:0.2", "Hooked escape/thrash difficulty multiplier by Angler level."); BarCurve = ((BaseUnityPlugin)this).Config.Bind<string>("Perks", "BarBonusByLevel", "0:0, 10:8, 30:24, 50:48, 75:72, 100:96", "Extra catch-bar height (pixels) by Angler level, on top of Hooked's own skill bonus."); DoubleLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "DoubleCatchLevel", 30, "Double catch level."); DoubleChance = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "DoubleCatchChance", 0.25f, "Double catch: chance a landed fish comes with a second one."); LineLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "StrongLineLevel", 35, "Strong line level."); LineSaving = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "StrongLineStaminaSaving", 0.3f, "Strong line: reeling and holding a hooked fish cost this much less stamina."); BigLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "BigCatchLevel", 45, "Big catch level."); BigChance = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "BigCatchChance", 0.25f, "Big catch: chance a landed fish is one size bigger."); SenseLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "FishSenseLevel", 50, "Fish sense level (button in the Professions window)."); SenseRange = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "FishSenseRange", 80f, "Fish sense: fish within this range are marked on the map for a minute."); BoatLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "BoatAnglerLevel", 55, "Boat angler level."); BoatBonus = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "BoatAnglerLineBonus", 0.5f, "Boat angler: the line reaches this much further and breaks this much later (fishing from a moving ship)."); MasterLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "MasterAnglerLevel", 100, "Master angler level."); MasterDoubleChance = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "MasterAnglerDoubleChance", 0.5f, "Master angler: Double catch chance becomes this."); Minigame.Bind(((BaseUnityPlugin)this).Config); Content.AddAction("Fishing", SenseLevel.Value, "Read the water", (Func<string>)FishSense); Api.RegisterLadder("Fishing", "VargheimFishing 1.1.0", "The game's Fishing skill. Simple Bait is open to everyone; Forest Bait and every bait above it, lures and modded rods are yours to make, by tier. Your tier materials (fish oil, glue, salt...) go into fish dishes, capes and magic gear.", (Perk[])(object)new Perk[7] { new Perk(SteadyLevel.Value, "Steady hands", "The fish fights less as you level: in Hooked it moves slower and your catch bar grows; in the Vargheim fight your line builds tension slower and the fish runs less often (x0.9 at 10, x0.6 at 50, x0.45 at 75)."), new Perk(DoubleLevel.Value, "Double catch", Mathf.RoundToInt(DoubleChance.Value * 100f) + "% chance a landed fish comes with a second one."), new Perk(LineLevel.Value, "Strong line", "Reeling and holding a hooked fish cost " + Mathf.RoundToInt(LineSaving.Value * 100f) + "% less stamina."), new Perk(BigLevel.Value, "Big catch", Mathf.RoundToInt(BigChance.Value * 100f) + "% chance a landed fish is one size bigger."), new Perk(SenseLevel.Value, "Fish sense", "'Read the water' in this window marks every fish within " + Mathf.RoundToInt(SenseRange.Value) + " m on the map for a minute."), new Perk(BoatLevel.Value, "Boat angler", "Your line reaches " + Mathf.RoundToInt(BoatBonus.Value * 100f) + "% further and breaks that much later: fish from a moving ship."), new Perk(MasterLevel.Value, "Master angler", "Double catch " + Mathf.RoundToInt(MasterDoubleChance.Value * 100f) + "%, and the fish barely fights (speed x0.4).") }); Harmony val = new Harmony("digi.vargheim.fishing"); val.PatchAll(typeof(Patches)); val.PatchAll(typeof(Minigame.MinigamePatches)); HookedBridge.Patch(val); ((BaseUnityPlugin)this).Logger.LogInfo((object)"VargheimFishing 1.1.0 loaded."); } internal static int Level() { return Api.PerkLevel("Fishing"); } internal static float Curve(string text, float level, float fallback) { List<KeyValuePair<float, float>> list = new List<KeyValuePair<float, float>>(); string[] array = (text ?? string.Empty).Split(','); foreach (string text2 in array) { int num = text2.IndexOf(':'); if (num > 0 && float.TryParse(text2.Substring(0, num).Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(text2.Substring(num + 1).Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { list.Add(new KeyValuePair<float, float>(result, result2)); } } if (list.Count == 0) { return fallback; } list.Sort((KeyValuePair<float, float> x, KeyValuePair<float, float> y) => x.Key.CompareTo(y.Key)); if (level <= list[0].Key) { return list[0].Value; } for (int num2 = 1; num2 < list.Count; num2++) { if (level <= list[num2].Key) { float num3 = (level - list[num2 - 1].Key) / Mathf.Max(0.01f, list[num2].Key - list[num2 - 1].Key); return Mathf.Lerp(list[num2 - 1].Value, list[num2].Value, num3); } } return list[list.Count - 1].Value; } private static string FishSense() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0058: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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)Minimap.instance == (Object)null) { return "Not in game."; } ClearSense(); int num = 0; foreach (Fish instance in Fish.Instances) { Fish val = instance; if (!((Object)(object)val == (Object)null) && !(Vector3.Distance(((Component)val).transform.position, ((Component)localPlayer).transform.position) > SenseRange.Value)) { string text = (((Object)(object)ItemOf(val) != (Object)null && ItemOf(val).m_itemData != null) ? Localization.instance.Localize(ItemOf(val).m_itemData.m_shared.m_name) : "Fish"); PinData val2 = Minimap.instance.AddPin(((Component)val).transform.position, (PinType)3, text, false, false, 0L, default(PlatformUserID)); if (val2 != null) { s_sensePins.Add(val2); num++; } } } s_senseUntil = Time.time + 60f; if (num != 0) { return num + " fish marked on the map for a minute."; } return "No fish within " + Mathf.RoundToInt(SenseRange.Value) + " m."; } private static void ClearSense() { if ((Object)(object)Minimap.instance != (Object)null) { foreach (PinData s_sensePin in s_sensePins) { if (s_sensePin != null) { Minimap.instance.RemovePin(s_sensePin); } } } s_sensePins.Clear(); } private void Update() { if (s_sensePins.Count > 0 && Time.time > s_senseUntil) { ClearSense(); } } private void OnGUI() { Minigame.OnGUI(); } } internal static class HookedBridge { internal static bool Found; private static Type s_session; private static Type s_bar; private static PropertyInfo s_active; private static FieldInfo s_sessBar; private static FieldInfo s_sessPlayer; private static FieldInfo s_sessPreset; private static FieldInfo s_sessSkill; private static FieldInfo s_sessBase; private static FieldInfo s_barDifficulty; private static FieldInfo s_barHeight; private static FieldInfo s_barMin; private static FieldInfo s_barTrack; private static FieldInfo s_barWander; private static FieldInfo s_presetEscape; internal static void Patch(Harmony h) { //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_025a: Expected O, but got Unknown try { Assembly assembly = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { if (string.Equals(assembly2.GetName().Name, "Hooked", StringComparison.OrdinalIgnoreCase)) { assembly = assembly2; break; } } if (assembly == null) { Plugin.Log("Hooked not loaded: minigame perks off."); return; } s_session = assembly.GetType("Hooked.Fishing.FishingSession"); s_bar = assembly.GetType("Hooked.Fishing.BobberBar"); Type type = assembly.GetType("Hooked.Fishing.DifficultyTuning"); if (s_session == null || s_bar == null || type == null) { Plugin.Warn("Hooked: FishingSession/BobberBar not found (different version?): minigame perks off."); return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; s_active = s_session.GetProperty("Active", bindingAttr); s_sessBar = s_session.GetField("Bar", bindingAttr); s_sessPlayer = s_session.GetField("player", bindingAttr); s_sessPreset = s_session.GetField("preset", bindingAttr); s_sessSkill = s_session.GetField("SkillLevel", bindingAttr); s_sessBase = s_session.GetField("baseDifficulty", bindingAttr); s_barDifficulty = s_bar.GetField("Difficulty", bindingAttr); s_barHeight = s_bar.GetField("BarHeight", bindingAttr); s_barMin = s_bar.GetField("MinDifficulty", bindingAttr); s_barTrack = s_bar.GetField("TrackHeight", bindingAttr); s_barWander = s_bar.GetField("WanderScale", bindingAttr); s_presetEscape = type.GetField("Escape", bindingAttr); MethodInfo method = s_session.GetMethod("Start", bindingAttr, null, new Type[2] { typeof(FishingFloat), typeof(Fish) }, null); if (method == null || s_sessBar == null || s_barDifficulty == null || s_barHeight == null) { Plugin.Warn("Hooked: session members not found: minigame perks off."); return; } h.Patch((MethodBase)method, new HarmonyMethod(typeof(HookedBridge), "BeforeStart", (Type[])null), new HarmonyMethod(typeof(HookedBridge), "AfterStart", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Found = true; Plugin.Log("Hooked minigame perks on."); } catch (Exception ex) { Plugin.Warn("Hooked bridge: " + ex.Message); } } private static bool BeforeStart() { return !Minigame.Active; } private static void AfterStart() { try { if (!Api.Active) { return; } object obj = ((s_active != null) ? s_active.GetValue(null, null) : null); if (obj == null) { return; } Player val = (Player)((s_sessPlayer != null) ? ((object)/*isinst with value type is only supported in some contexts*/) : ((object)Player.m_localPlayer)); if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)Player.m_localPlayer) { return; } object value = s_sessBar.GetValue(obj); if (value != null) { float num = Plugin.Level(); if (num < (float)Plugin.SteadyLevel.Value) { num = 0f; } float num2 = Mathf.Clamp(Plugin.Curve(Plugin.SpeedCurve.Value, num, 1f), 0.1f, 2f); float num3 = Mathf.Clamp(Plugin.Curve(Plugin.ThrashCurve.Value, num, 1f), 0f, 2f); float num4 = Mathf.Max(0f, Plugin.Curve(Plugin.BarCurve.Value, num, 0f)); if (s_sessBase != null) { s_sessBase.SetValue(obj, (float)s_sessBase.GetValue(obj) * num2); } float num5 = (float)s_barDifficulty.GetValue(value); float num6 = ((s_barMin != null) ? ((float)s_barMin.GetValue(null)) : 0f); s_barDifficulty.SetValue(value, Mathf.Max(num6, num5 * num2)); float num7 = (float)s_barHeight.GetValue(value); float num8 = ((s_barTrack != null) ? ((float)s_barTrack.GetValue(null)) : 0f); float num9 = num7 + num4; if (num8 > 0f) { num9 = Mathf.Min(num9, num8 * 0.9f); } s_barHeight.SetValue(value, num9); if (s_barWander != null) { s_barWander.SetValue(value, (float)s_barWander.GetValue(value) * num2); } if (s_sessPreset != null && s_presetEscape != null) { object value2 = s_sessPreset.GetValue(obj); float num10 = (float)s_presetEscape.GetValue(value2); s_presetEscape.SetValue(value2, num10 * num3); s_sessPreset.SetValue(obj, value2); } if (num > 0f) { Plugin.Log("angler " + Mathf.FloorToInt(num) + ": fish speed x" + num2.ToString("0.00") + ", thrash x" + num3.ToString("0.00") + ", bar " + num7.ToString("0") + " -> " + num9.ToString("0")); } } } catch (Exception ex) { Plugin.Warn("Hooked angler tuning: " + ex.Message); } } } internal static class Minigame { internal enum Mode { Hooked, Vargheim } [HarmonyPatch] internal static class MinigamePatches { [HarmonyPatch(typeof(FishingFloat), "FixedUpdate")] [HarmonyPostfix] private static void FixedUpdate(FishingFloat __instance) { try { if (!Active || (Object)(object)__instance == (Object)null) { return; } ZNetView value = Traverse.Create((object)__instance).Field("m_nview").GetValue<ZNetView>(); if (!((Object)(object)value == (Object)null) && value.IsValid() && value.IsOwner()) { Character value2 = Traverse.Create((object)__instance).Method("GetOwner", Array.Empty<object>()).GetValue<Character>(); if (!((Object)(object)value2 == (Object)null) && !((Object)(object)value2 != (Object)(object)Player.m_localPlayer)) { Step(__instance, value2, Time.fixedDeltaTime); } } } catch (Exception ex) { Plugin.Warn("minigame: " + ex.Message); } } } internal static ConfigEntry<Mode> ModeSetting; private static ConfigEntry<float> s_gainReel; private static ConfigEntry<float> s_gainRun; private static ConfigEntry<float> s_decay; private static ConfigEntry<float> s_runMin; private static ConfigEntry<float> s_runMax; private static ConfigEntry<float> s_runLenMin; private static ConfigEntry<float> s_runLenMax; private static ConfigEntry<float> s_forceForMax; private static ConfigEntry<float> s_snapGrace; private static ConfigEntry<bool> s_showBar; private static FishingFloat s_float; private static float s_tension; private static float s_nextRun; private static float s_runUntil; private static float s_startLine; private static float s_graceUntil; private static bool s_running; private static Texture2D s_white; internal static bool Active { get { if (ModeSetting != null) { return ModeSetting.Value == Mode.Vargheim; } return false; } } internal static void Bind(ConfigFile cfg) { ModeSetting = cfg.Bind<Mode>("Minigame", "Mode", Mode.Hooked, "Hooked: Azumatt's bobber-bar minigame (with the Angler tuning). Vargheim: this mod's line-tension fight instead (Hooked's fight is skipped)."); s_gainReel = cfg.Bind<float>("Minigame", "TensionWhileReeling", 0.35f, "Vargheim mode: tension gained per second while reeling a calm fish."); s_gainRun = cfg.Bind<float>("Minigame", "TensionWhileRunning", 1.1f, "Vargheim mode: tension gained per second while reeling a running fish."); s_decay = cfg.Bind<float>("Minigame", "TensionDecay", 0.6f, "Vargheim mode: tension lost per second while not reeling."); s_runMin = cfg.Bind<float>("Minigame", "RunEveryMin", 2.5f, "Vargheim mode: shortest pause between runs (seconds, for the hardest fish)."); s_runMax = cfg.Bind<float>("Minigame", "RunEveryMax", 6f, "Vargheim mode: longest pause between runs (seconds, for the easiest fish)."); s_runLenMin = cfg.Bind<float>("Minigame", "RunLengthMin", 0.7f, "Vargheim mode: shortest run (seconds)."); s_runLenMax = cfg.Bind<float>("Minigame", "RunLengthMax", 1.8f, "Vargheim mode: longest run (seconds, for the hardest fish)."); s_forceForMax = cfg.Bind<float>("Minigame", "HookForceForHardest", 8f, "Vargheim mode: a fish with this hook force (or more) counts as the hardest."); s_snapGrace = cfg.Bind<float>("Minigame", "SnapGrace", 0.25f, "Vargheim mode: seconds the gauge may sit at the top before the line snaps."); s_showBar = cfg.Bind<bool>("Minigame", "ShowGauge", true, "Vargheim mode: draw the tension gauge."); } private static void Reset() { s_float = null; s_tension = 0f; s_running = false; s_nextRun = 0f; s_runUntil = 0f; s_graceUntil = 0f; } private static float Difficulty(Fish fish) { return Mathf.Clamp01((((Object)(object)fish != (Object)null) ? fish.m_hookForce : 1f) / Mathf.Max(0.1f, s_forceForMax.Value)); } private static bool Reeling(Character owner) { if ((Object)(object)owner != (Object)null && owner.IsBlocking()) { return owner.HaveStamina(0f); } return false; } internal static void Step(FishingFloat ff, Character owner, float dt) { if (!Active || (Object)(object)ff == (Object)null) { return; } Fish val = ff.GetCatch(); if ((Object)(object)val == (Object)null) { if ((Object)(object)s_float == (Object)(object)ff) { Reset(); } return; } if ((Object)(object)s_float != (Object)(object)ff) { Reset(); s_float = ff; s_startLine = Mathf.Max(1f, Traverse.Create((object)ff).Field("m_lineLength").GetValue<float>()); s_nextRun = Time.time + Random.Range(1f, 2.5f); } float num = Plugin.Level(); if (num < (float)Plugin.SteadyLevel.Value) { num = 0f; } float num2 = Mathf.Clamp(Plugin.Curve(Plugin.SpeedCurve.Value, num, 1f), 0.1f, 2f); float num3 = Mathf.Clamp(Plugin.Curve(Plugin.ThrashCurve.Value, num, 1f), 0f, 2f); float num4 = Difficulty(val); bool flag = val.IsEscaping(); if (!s_running && (flag || Time.time >= s_nextRun)) { s_running = true; s_runUntil = Time.time + Mathf.Lerp(s_runLenMin.Value, s_runLenMax.Value, num4) * Mathf.Max(0.3f, num2); } if (s_running && Time.time >= s_runUntil && !flag) { s_running = false; float num5 = Mathf.Lerp(s_runMax.Value, s_runMin.Value, num4); s_nextRun = Time.time + num5 / Mathf.Max(0.2f, num3); } if (Reeling(owner)) { s_tension += (s_running ? s_gainRun.Value : s_gainReel.Value) * num2 * dt; } else { s_tension -= s_decay.Value * dt; } s_tension = Mathf.Clamp01(s_tension); if (s_tension >= 1f) { if (s_graceUntil <= 0f) { s_graceUntil = Time.time + s_snapGrace.Value; } else if (Time.time >= s_graceUntil) { Snap(ff, val, owner); } } else { s_graceUntil = 0f; } } private static void Snap(FishingFloat ff, Fish fish, Character owner) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) try { if ((Object)(object)owner != (Object)null) { owner.Message((MessageType)2, "$msg_fishing_linebroke", 0, (Sprite)null, false); } fish.OnHooked((FishingFloat)null); Traverse obj = Traverse.Create((object)ff); EffectList value = obj.Field("m_lineBreakEffect").GetValue<EffectList>(); if (value != null) { value.Create(((Component)ff).transform.position, ((Component)ff).transform.rotation, (Transform)null, 1f, -1, default(ZDOID)); } ZNetView value2 = obj.Field("m_nview").GetValue<ZNetView>(); if ((Object)(object)value2 != (Object)null && value2.IsValid()) { value2.Destroy(); } } catch (Exception ex) { Plugin.Warn("minigame snap: " + ex.Message); } Reset(); } internal static void OnGUI() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_017e: 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_01ac: 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_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01ea: 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_0053: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) if (Active && s_showBar.Value && !((Object)(object)s_float == (Object)null) && !((Object)(object)s_float.GetCatch() == (Object)null) && !Hud.IsUserHidden()) { if ((Object)(object)s_white == (Object)null) { s_white = new Texture2D(1, 1); s_white.SetPixel(0, 0, Color.white); s_white.Apply(); } float num = 320f; float num2 = 18f; float num3 = ((float)Screen.width - num) * 0.5f; float num4 = (float)Screen.height * 0.78f; float value = Traverse.Create((object)s_float).Field("m_lineLength").GetValue<float>(); float num5 = 1f - Mathf.Clamp01(value / s_startLine); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.6f); GUI.DrawTexture(new Rect(num3 - 4f, num4 - 4f, num + 8f, num2 * 2f + 16f), (Texture)(object)s_white); GUI.color = Color.Lerp(new Color(0.3f, 0.9f, 0.3f), new Color(0.95f, 0.2f, 0.15f), s_tension * s_tension); GUI.DrawTexture(new Rect(num3, num4, num * s_tension, num2), (Texture)(object)s_white); GUI.color = new Color(0.55f, 0.75f, 1f); GUI.DrawTexture(new Rect(num3, num4 + num2 + 4f, num * num5, num2 * 0.6f), (Texture)(object)s_white); GUI.color = Color.white; GUIStyle val = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 14, fontStyle = (FontStyle)1 }; GUI.Label(new Rect(num3, num4 - 22f, num, 20f), s_running ? "The fish runs - ease off!" : "Reel", val); GUI.color = color; } } } }