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 RobsFishing v1.0.1
RobsFishing.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [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 RobsFishing { [BepInPlugin("com.robsfishing.mod", "Rob's Fishing", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class RobsFishingPlugin : BaseUnityPlugin { public const string ModGuid = "com.robsfishing.mod"; public const string ModName = "Rob's Fishing"; public const string ModVersion = "1.0.0"; public const string RodPrefabName = "RobsFishingRod"; private const string BaseRodPrefab = "FishingRod"; private const string GlowSourcePrefab = "BowDraugrFang"; internal static readonly int RodFlagHash = StringExtensionMethods.GetStableHashCode("RobsFishing_Float"); internal static ConfigEntry<float> SuckRadius; internal static ConfigEntry<float> SkillXpPerFish; internal static ConfigEntry<bool> LogGlowSource; internal static ManualLogSource Log; private void Awake() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; SuckRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SuckRadius", 10f, "Radius in meters around the float from which all fish are pulled to you."); SkillXpPerFish = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SkillXpPerFish", 3f, "Fishing skill XP granted per fish caught (vanilla gives ~1 per second of reeling)."); LogGlowSource = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogGlowSource", false, "Log the Draugr Fang Bow's hierarchy at startup (to see where the glow comes from)."); PrefabManager.OnVanillaPrefabsAvailable += AddRod; new Harmony("com.robsfishing.mod").PatchAll(); } private void AddRod() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= AddRod; ItemConfig val = new ItemConfig { Name = "Rob's Fishing Rod", Description = "A rod humming with draugr power. Hook a fish and every fish within range is dragged straight to you - no struggle.", CraftingStation = CraftingStations.Workbench, Requirements = GetVanillaRequirements() }; CustomItem val2 = new CustomItem("RobsFishingRod", "FishingRod", val); ItemManager.Instance.AddItem(val2); AddGlow(val2.ItemPrefab); AddToTrader(val2.ItemPrefab); } private static void AddToTrader(GameObject rod) { //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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("Haldor"); Trader val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Trader>() : null); if (!Object.op_Implicit((Object)(object)val)) { Log.LogWarning((object)"Could not find Haldor; rod not added to the shop."); return; } TradeItem val2 = ((IEnumerable<TradeItem>)val.m_items).FirstOrDefault((Func<TradeItem, bool>)((TradeItem i) => Object.op_Implicit((Object)(object)i.m_prefab) && ((Object)i.m_prefab).name == "FishingRod")); if (val2 == null) { Log.LogWarning((object)"Haldor does not sell the vanilla rod; rod not added to the shop."); return; } val.m_items.Add(new TradeItem { m_prefab = rod.GetComponent<ItemDrop>(), m_stack = val2.m_stack, m_price = val2.m_price, m_requiredGlobalKey = val2.m_requiredGlobalKey }); } private static RequirementConfig[] GetVanillaRequirements() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown Recipe val = ((IEnumerable<Recipe>)ObjectDB.instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)((Recipe r) => Object.op_Implicit((Object)(object)r.m_item) && ((Object)r.m_item).name == "FishingRod")); if ((Object)(object)val == (Object)null) { return (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("LeatherScraps", 4, 0, true) }; } return ((IEnumerable<Requirement>)val.m_resources).Select((Func<Requirement, RequirementConfig>)((Requirement r) => new RequirementConfig(((Object)r.m_resItem).name, r.m_amount, r.m_amountPerLevel, true))).ToArray(); } private static void AddGlow(GameObject rod) { //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) GameObject bow = PrefabManager.Instance.GetPrefab("BowDraugrFang"); if (!Object.op_Implicit((Object)(object)bow)) { Log.LogWarning((object)"Could not find BowDraugrFang; the rod will not glow."); return; } if (LogGlowSource.Value) { Transform[] componentsInChildren = bow.GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { string text = string.Join(",", from c in ((Component)val).GetComponents<Component>() where Object.op_Implicit((Object)(object)c) select ((object)c).GetType().Name); Log.LogInfo((object)("bow: " + GetPath(val, bow.transform) + " [" + text + "]")); } } foreach (Transform item in (from t in bow.GetComponentsInChildren<Transform>(true) where (Object)(object)t != (Object)(object)bow.transform && IsGlow(t) && !HasGlowAncestor(t, bow.transform) select t).ToList()) { string path = GetPath(item.parent, bow.transform); Transform val2 = (string.IsNullOrEmpty(path) ? rod.transform : rod.transform.Find(path)); if (!Object.op_Implicit((Object)(object)val2)) { val2 = rod.transform.Find("attach") ?? rod.transform; } GameObject obj = Object.Instantiate<GameObject>(((Component)item).gameObject, val2, false); ((Object)obj).name = ((Object)item).name; obj.transform.localPosition = CenterOffset(val2, item); obj.transform.localRotation = AlignToRod(bow.transform, item, val2) * item.localRotation; LongAxis(item.parent, out var length); LongAxis(val2, out var length2); float num = ((length > 0.01f && length2 > 0.01f) ? Mathf.Clamp(length2 / length, 1f, 4f) : 1f); obj.transform.localScale = item.localScale * num; Log.LogInfo((object)("Added glow object '" + ((Object)item).name + "' to " + GetPath(val2, rod.transform))); } } private static Quaternion AlignToRod(Transform bowRoot, Transform src, Transform rodParent) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = LongAxis(src.parent); Vector3 val2 = LongAxis(rodParent); if (val == Vector3.zero || val2 == Vector3.zero) { return Quaternion.identity; } return Quaternion.FromToRotation(val, val2); } private static Vector3 LongAxis(Transform space) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) float length; return LongAxis(space, out length); } private static Vector3 LongAxis(Transform space, out float length) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0081: 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_0097: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) List<MeshFilter> list = (from m in ((Component)space).GetComponentsInChildren<MeshFilter>(true) where Object.op_Implicit((Object)(object)m.sharedMesh) select m).ToList(); length = 0f; if (list.Count == 0) { return Vector3.zero; } Bounds val = default(Bounds); bool flag = true; foreach (MeshFilter item in list) { Bounds mb = item.sharedMesh.bounds; Matrix4x4 val2 = space.worldToLocalMatrix * ((Component)item).transform.localToWorldMatrix; foreach (Vector3 item2 in new float[2] { -1f, 1f }.SelectMany((float x) => new float[2] { -1f, 1f }.SelectMany((float y) => new float[2] { -1f, 1f }.Select((float z) => ((Bounds)(ref mb)).center + Vector3.Scale(((Bounds)(ref mb)).extents, new Vector3(x, y, z)))))) { Vector3 val3 = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(item2); if (flag) { val = new Bounds(val3, Vector3.zero); flag = false; } else { ((Bounds)(ref val)).Encapsulate(val3); } } } Vector3 size = ((Bounds)(ref val)).size; length = Mathf.Max(new float[3] { size.x, size.y, size.z }); if (!(size.x >= size.y) || !(size.x >= size.z)) { if (!(size.y >= size.z)) { return Vector3.forward; } return Vector3.up; } return Vector3.right; } private static Vector3 CenterOffset(Transform parent, Transform src) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) MeshRenderer[] componentsInChildren = ((Component)parent).GetComponentsInChildren<MeshRenderer>(true); if (componentsInChildren.Length == 0) { return src.localPosition; } Bounds bounds = ((Renderer)componentsInChildren[0]).bounds; foreach (MeshRenderer item in componentsInChildren.Skip(1)) { ((Bounds)(ref bounds)).Encapsulate(((Renderer)item).bounds); } return parent.InverseTransformPoint(((Bounds)(ref bounds)).center); } private static bool IsGlow(Transform t) { if (!Object.op_Implicit((Object)(object)((Component)t).GetComponent<ParticleSystem>())) { return Object.op_Implicit((Object)(object)((Component)t).GetComponent<Light>()); } return true; } private static bool HasGlowAncestor(Transform t, Transform stop) { Transform parent = t.parent; while (Object.op_Implicit((Object)(object)parent) && (Object)(object)parent != (Object)(object)stop) { if (IsGlow(parent)) { return true; } parent = parent.parent; } return false; } private static string GetPath(Transform t, Transform root) { if (!Object.op_Implicit((Object)(object)t) || (Object)(object)t == (Object)(object)root) { return ""; } List<string> list = new List<string>(); while (Object.op_Implicit((Object)(object)t) && (Object)(object)t != (Object)(object)root) { list.Insert(0, ((Object)t).name); t = t.parent; } return string.Join("/", list); } } [HarmonyPatch] internal static class FishingPatches { [HarmonyPatch(typeof(FishingFloat), "Setup")] [HarmonyPostfix] private static void Setup_Postfix(FishingFloat __instance, ItemData item) { if (!((Object)(object)item?.m_dropPrefab == (Object)null) && !(((Object)item.m_dropPrefab).name != "RobsFishingRod")) { ZNetView value = Traverse.Create((object)__instance).Field("m_nview").GetValue<ZNetView>(); if ((Object)(object)value != (Object)null && value.IsValid() && value.IsOwner()) { value.GetZDO().Set(RobsFishingPlugin.RodFlagHash, true); } } } [HarmonyPatch(typeof(FishingFloat), "TryToHook")] [HarmonyPrefix] private static bool TryToHook_Prefix(FishingFloat __instance) { Traverse val = Traverse.Create((object)__instance); ZNetView value = val.Field("m_nview").GetValue<ZNetView>(); if ((Object)(object)value == (Object)null || !value.IsValid() || !value.IsOwner()) { return true; } if (!value.GetZDO().GetBool(RobsFishingPlugin.RodFlagHash, false)) { return true; } Fish value2 = val.Field("m_nibbler").GetValue<Fish>(); float value3 = val.Field("m_nibbleTime").GetValue<float>(); if ((Object)(object)value2 == (Object)null || Time.time - value3 >= 0.5f || (Object)(object)__instance.GetCatch() != (Object)null) { return false; } Character value4 = val.Method("GetOwner", Array.Empty<object>()).GetValue<Character>(); if ((Object)(object)value4 == (Object)null) { return false; } Vacuum(__instance, val, value4, value); return false; } private static void Vacuum(FishingFloat ff, Traverse tr, Character owner, ZNetView nview) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) Vector3 center = ((Component)ff).transform.position; float value = RobsFishingPlugin.SuckRadius.Value; float sqr = value * value; List<Fish> list = Fish.Instances.OfType<Fish>().Where(delegate(Fish f) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)f)) { Vector3 val2 = ((Component)f).transform.position - center; return ((Vector3)(ref val2)).sqrMagnitude <= sqr; } return false; }).ToList(); tr.Field("m_baitConsumed").SetValue((object)true); Game.instance.IncrementPlayerStat((PlayerStatType)158, 1f, false); int num = 0; Humanoid val = (Humanoid)(object)((owner is Humanoid) ? owner : null); foreach (Fish item in list) { if (Object.op_Implicit((Object)(object)val) && val.GetInventory().CanAddItem(Object.op_Implicit((Object)(object)item.m_pickupItem) ? item.m_pickupItem : ((Component)item).gameObject, item.m_pickupItemStackSize)) { FishingFloat.Catch(item, owner); num++; } } if (num > 0) { owner.RaiseSkill((SkillType)104, RobsFishingPlugin.SkillXpPerFish.Value * (float)num); } string text = ((num == 0) ? "$msg_fishing_lost" : ("Reeled in " + num + ((num == 1) ? " fish!" : " fish!"))); owner.Message((MessageType)2, Localization.instance.Localize(text), 0, (Sprite)null, false); nview.Destroy(); } } }