using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Size2Fix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Fixes bug that made the size 2 fish uncatchable.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Size2Fix")]
[assembly: AssemblyTitle("Size2Fix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Size2Fix
{
[BepInPlugin("com.earthlingOnFire.Size2Fix", "Size 2 Fix", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.earthlingOnFire.Size2Fix";
public const string PLUGIN_NAME = "Size 2 Fix";
public const string PLUGIN_VERSION = "1.0.1";
internal static ConfigEntry<bool> hasCaughtSize2;
internal static ConfigEntry<int> probability;
public void Awake()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
probability = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Probability", 10, new ConfigDescription("Probability of a fish's size being 2.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
hasCaughtSize2 = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Has Caught Size 2", false, "Whether or not a size 2 fish has been caught yet. Will be set to \"true\" when a fish of size 2 is caught.");
}
public void Start()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
new Harmony("com.earthlingOnFire.Size2Fix").PatchAll();
}
}
[HarmonyPatch]
internal static class Patches
{
private static readonly Vector3 fishSize2 = Vector3.one * 1.2f;
private static readonly Vector3 sharkSize2 = Vector3.one * 0.8f;
private static readonly Vector3 dopeSize2 = Vector3.one * 0.8f;
private static readonly Vector3 fishWorldSize2 = Vector3.one * 2f;
[HarmonyPostfix]
[HarmonyPatch(typeof(LeaderboardController), "GetFishScores")]
private static async void LeaderboardController_GetFishScores_Postfix(Task<LeaderboardEntry[]> __result, LeaderboardType type)
{
//IL_0019: 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)
LeaderboardEntry[] leaderboard = await __result;
if (leaderboard == null || !Plugin.hasCaughtSize2.Value)
{
return;
}
int targetIndex = Array.FindIndex(leaderboard, (LeaderboardEntry e) => e.Score == 1);
if (targetIndex < 0)
{
return;
}
int userIndex = Array.FindIndex(leaderboard, (LeaderboardEntry e) => ((Friend)(ref e.User)).IsMe);
if (userIndex >= 0)
{
if (leaderboard[userIndex].Score == 2)
{
return;
}
Friend otherUser = leaderboard[targetIndex].User;
leaderboard[userIndex].User = otherUser;
}
else
{
targetIndex = 2;
}
leaderboard[targetIndex].User = new Friend(SteamClient.SteamId);
leaderboard[targetIndex].Score = 2;
leaderboard[targetIndex].GlobalRank = 3;
}
private static bool NextFishIsSize2()
{
return Random.Range(0, 100) < Plugin.probability.Value;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FishBait), "CatchFish")]
private static void FishBait_CatchFish_Prefix(FishBait __instance, out bool __state)
{
__state = !__instance.returnToRod;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(FishBait), "CatchFish")]
private static void FishBait_CatchFish_Postfix(FishBait __instance, bool __state)
{
//IL_003f: 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)
if (__state && NextFishIsSize2())
{
GameObject gameObject = ((Component)__instance.spawnedFish).gameObject;
((Object)gameObject).name = ((Object)gameObject).name + " (size 2)";
Transform transform = gameObject.transform;
transform.localScale *= 2f;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FishBait), "ReturnAnim")]
private static bool FishBait_ReturnAnim_Prefix(FishBait __instance)
{
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: 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_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
if (__instance.flyProgress < 1f)
{
return true;
}
GameObject gameObject = ((Component)__instance.spawnedFish).gameObject;
FishingRodWeapon sourceWeapon = __instance.sourceWeapon;
__instance.flyProgress = 1f;
sourceWeapon.animator.SetTrigger("Idle");
MonoSingleton<FishingHUD>.Instance.ShowFishCaught(true, sourceWeapon.hookedFishe.fish);
GameObject val = FishingRodWeapon.CreateFishPickup(sourceWeapon.fishPickupTemplate, sourceWeapon.hookedFishe.fish, true, true);
sourceWeapon.ResetFishing();
sourceWeapon.pullSound.Stop();
Object.Destroy((Object)(object)gameObject.gameObject);
try
{
MonoSingleton<LeaderboardController>.Instance.SubmitFishSize(SteamController.FishSizeMulti);
}
catch
{
}
UpdateSizeText(gameObject);
if (!((Object)gameObject).name.Contains("size 2"))
{
return true;
}
Plugin.hasCaughtSize2.Value = true;
GameObject val2 = val.FindNonDummyChild();
((Object)val2).name = ((Object)val2).name + " (size 2)";
Vector3 val3 = (((Object)val2).name.Contains("Dope") ? dopeSize2 : ((!((Object)val2).name.Contains("Shark")) ? fishSize2 : sharkSize2));
val2.GetComponentInParent<ItemIdentifier>().putDownScale = val3;
val.transform.localScale = val3;
GameObject obj2 = GameObject.Find("Fish Scores");
if (obj2 != null)
{
FishLeaderboard component = obj2.GetComponent<FishLeaderboard>();
if (component != null)
{
component.Fetch();
}
}
GameObject val4 = GameObject.Find("FinalRoom 2");
Transform val5 = val4.transform.Find("Room/Testament Shop/Canvas/Border/TipBox/Panel/");
string text = "<size=40><b><color=red>Y O U W E R E\nN O T\nS U P P O S E D\nT O D O T H A T</color></b></size>";
((TMP_Text)((Component)val5.Find("Title")).gameObject.GetComponent<TextMeshProUGUI>()).text = "";
((TMP_Text)((Component)val5.Find("Text")).gameObject.GetComponent<TextMeshProUGUI>()).text = text;
return false;
}
private static void UpdateSizeText(GameObject fish)
{
GameObject val = GameObject.Find("FishingCanvas/Fish Caught/Fish Size Text");
Text component = val.GetComponent<Text>();
if (((Object)fish).name.Contains("size 2"))
{
component.text = "SIZE: 2";
}
else
{
component.text = "SIZE: 1";
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Punch), "ForceHold")]
private static void Punch_ForceHold_Postfix(Punch __instance)
{
ItemIdentifier heldItem = __instance.heldItem;
if (((Component)heldItem).transform.childCount > 0)
{
Transform child = ((Component)heldItem).transform.GetChild(0);
if (((Object)child).name.Contains("Cooked Fish"))
{
UpdateSizeText(((Component)child).gameObject);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Punch), "ResetHeldItemPosition")]
private static void Punch_ResetHeldItemPosition_Postfix(Punch __instance)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
ItemIdentifier heldItem = __instance.heldItem;
if (heldItem.IsSize2())
{
((Component)heldItem).transform.localScale = heldItem.putDownScale;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Punch), "ForceThrow")]
private static void Punch_ForceThrow_Prefix(out ItemIdentifier __state, Punch __instance)
{
ItemIdentifier heldItem = __instance.heldItem;
if (heldItem.IsSize2())
{
__state = heldItem;
}
else
{
__state = null;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Punch), "ForceThrow")]
private static void Punch_ForceThrow_Postfix(ItemIdentifier __state)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)__state))
{
((Component)__state).transform.localScale = fishWorldSize2;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static Transform MonoBehaviourTransform(Component instance)
{
return instance.transform;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FishCooker), "OnTriggerEnter")]
private static bool FishCooker_OnTriggerEnter_Prefix(Collider other, FishCooker __instance)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: 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_01a9: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: 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_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_024c: 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_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
Vector3 putDownScale = __instance.fishPickupTemplate.putDownScale;
bool flag = false;
for (int i = 0; i < ((Component)other).transform.childCount; i++)
{
GameObject gameObject = ((Component)((Component)other).transform.GetChild(i)).gameObject;
if (((Object)gameObject).name.Contains("size 2"))
{
putDownScale = fishSize2;
flag = true;
break;
}
}
ItemIdentifier val = Object.Instantiate<ItemIdentifier>(__instance.fishPickupTemplate);
val.putDownScale = putDownScale;
FishObjectReference val2 = default(FishObjectReference);
if (!((Component)other).TryGetComponent<FishObjectReference>(ref val2))
{
return false;
}
FishObject fishObject = val2.fishObject;
if (__instance.unusable)
{
if (TimeSince.op_Implicit(__instance.timeSinceLastError) > 2f)
{
__instance.timeSinceLastError = TimeSince.op_Implicit(0f);
MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("Too small for this fish.\n:^(", "", "", 0, false, false, true);
}
return false;
}
if ((Object)(object)fishObject == (Object)(object)__instance.cookedFish || (Object)(object)fishObject == (Object)(object)__instance.failedFish)
{
return false;
}
_ = MonoSingleton<FishManager>.Instance.recognizedFishes[__instance.cookedFish];
GameObject val3 = FishingRodWeapon.CreateFishPickup(val, fishObject.canBeCooked ? __instance.cookedFish : __instance.failedFish, false, false);
if (!fishObject.canBeCooked)
{
MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("Cooking failed.", "", "", 0, false, false, true);
}
Vector3 position = MonoBehaviourTransform((Component)(object)__instance).position;
Vector3 val4 = Vector3.Normalize(((Component)MonoSingleton<NewMovement>.Instance).transform.position - position);
val3.transform.SetPositionAndRotation(position, Quaternion.identity);
val3.GetComponent<Rigidbody>().velocity = val4 * 18f + Vector3.up * 10f;
if (flag)
{
GameObject val5 = val3.FindNonDummyChild();
if (val5 != null)
{
((Object)val5).name = ((Object)val5).name + " (size 2)";
val3.transform.localScale = fishWorldSize2;
}
}
Object.Instantiate<GameObject>(__instance.cookedSound, position, Quaternion.identity);
if (Object.op_Implicit((Object)(object)__instance.cookedParticles))
{
Object.Instantiate<GameObject>(__instance.cookedParticles, position, Quaternion.identity);
}
Object.Destroy((Object)(object)((Component)val2).gameObject);
return false;
}
}
internal static class Extensions
{
public static bool IsSize2(this ItemIdentifier item)
{
return (Object)(object)item != (Object)null && ((Component)item).transform.childCount > 0 && ((Object)((Component)item).transform.GetChild(0)).name.Contains("size 2");
}
public static GameObject FindNonDummyChild(this GameObject obj)
{
Transform transform = obj.transform;
for (int i = 0; i < transform.childCount; i++)
{
GameObject gameObject = ((Component)transform.GetChild(i)).gameObject;
if (((Object)gameObject).name != "Dummy Object")
{
return gameObject;
}
}
return null;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "Size2Fix";
public const string PLUGIN_NAME = "Size2Fix";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}