Decompiled source of FightingFish v1.0.3

plugins\TeflonTed.FightingFish.dll

Decompiled 20 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TeflonTed.FightingFish")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Teflon Ted's Fighting Fish — clear cue when a hooked fish starts fighting")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+5cc06240df91b35ea2e42b9de6d2d97761d40fe9")]
[assembly: AssemblyProduct("TeflonTed.FightingFish")]
[assembly: AssemblyTitle("TeflonTed.FightingFish")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[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 TeflonTed.FightingFish
{
	[BepInPlugin("com.teflonted.valheim.fightingfish", "Teflon Ted's Fighting Fish", "1.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.teflonted.valheim.fightingfish";

		public const string PluginName = "Teflon Ted's Fighting Fish";

		public const string PluginVersion = "1.0.3";

		private void Awake()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.teflonted.valheim.fightingfish");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Teflon Ted's Fighting Fish 1.0.3 loaded");
		}
	}
	[HarmonyPatch(typeof(Fish), "OnHooked")]
	internal static class Fish_OnHooked_Patch
	{
		private static void Prefix()
		{
			Fish_Escape_Patch.SuppressNextCue = true;
		}

		private static void Postfix()
		{
			Fish_Escape_Patch.SuppressNextCue = false;
		}
	}
	[HarmonyPatch(typeof(Fish), "Escape")]
	internal static class Fish_Escape_Patch
	{
		internal static bool SuppressNextCue;

		private static readonly string[] FightSfxPrefabs = new string[3] { "sfx_land_water", "sfx_blob_jump", "sfx_blob_land" };

		private static void Postfix(Fish __instance)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (SuppressNextCue)
			{
				SuppressNextCue = false;
			}
			else
			{
				if ((Object)(object)__instance == (Object)null || !__instance.IsHooked())
				{
					return;
				}
				FishingFloat fishingFloat = __instance.m_fishingFloat;
				if (!((Object)(object)fishingFloat == (Object)null))
				{
					Character owner = fishingFloat.GetOwner();
					if (!((Object)(object)owner == (Object)null) && !((Object)(object)owner != (Object)(object)Player.m_localPlayer))
					{
						owner.Message((MessageType)2, "Stop reeling!", 0, (Sprite)null, false);
						PlayFightSfx(((Component)__instance).transform.position);
					}
				}
			}
		}

		private static void PlayFightSfx(Vector3 position)
		{
			//IL_0032: 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)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			string[] fightSfxPrefabs = FightSfxPrefabs;
			foreach (string text in fightSfxPrefabs)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab(text);
				if (!((Object)(object)prefab == (Object)null))
				{
					Object.Instantiate<GameObject>(prefab, position, Quaternion.identity);
					break;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}