Decompiled source of Wolf Recall v1.0.4

WolfRecall.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace WolfRecall
{
	public enum ShieldState
	{
		None,
		Stun,
		Immortal
	}
	public static class ShieldColors
	{
		public static Dictionary<ShieldState, string> Colors = new Dictionary<ShieldState, string>
		{
			{
				ShieldState.None,
				"#FFFFFF"
			},
			{
				ShieldState.Stun,
				"#95c9da"
			},
			{
				ShieldState.Immortal,
				"#d8bf58"
			}
		};

		public static void UpdateColors(string stunColor, string immortalColor)
		{
			Colors[ShieldState.Stun] = stunColor;
			Colors[ShieldState.Immortal] = immortalColor;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("fai.WolfRecallPlugin", "Wolf Recall Simple", "1.0.2")]
	public class WolfRecall : BaseUnityPlugin
	{
		internal const string ModName = "SelectivePetProtection";

		internal const string ModVersion = "0.2.2";

		internal const string Author = "magnus";

		private const string ModGUID = "magnus.SelectivePetProtection";

		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private static string ClaimOwnership;

		public static ManualLogSource Log;

		public static bool isVikingNPCLoaded;

		private BaseUnityPlugin vikingNPCPlugin;

		public static Harmony harmony = new Harmony("fai.wolfrecall.harmony");

		private ConfigEntry<int> stunRecoveryTimeConfig;

		private ConfigEntry<string> m_targetCreature;

		private ConfigEntry<string> m_localPlayer;

		public static float stunRecoveryTime { get; internal set; }

		public static string stunShieldColor
		{
			[CompilerGenerated]
			get
			{
				return ClaimOwnership;
			}
			[CompilerGenerated]
			internal set
			{
				ClaimOwnership = value;
			}
		}

		public static string immortalShieldColor { get; internal set; }

		public static ConfigEntry<KeyboardShortcut> ToggleProtectionShortcut { get; set; }

		private void Start()
		{
		}

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			stunRecoveryTime = 0f;
			ToggleProtectionShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "RecallShortcut", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[0]), "Recall following tamed companions. Default: H.");
			harmony.PatchAll();
		}
	}
	[HarmonyPatch(typeof(Player), "UpdateHover")]
	public static class Player_UpdateHover_Patch
	{
		public static void Postfix(ref Player __instance)
		{
		}
	}
	[HarmonyPatch(typeof(Tameable), "RPC_SetName")]
	public static class Tameable_RPC_SetName_Patch
	{
		public static bool Prefix(ref Tameable __instance, ref string name)
		{
			return true;
		}
	}
	[HarmonyPatch(typeof(Tameable), "SetName")]
	public static class Tameable_SetName_Patch
	{
		public static bool Prefix(ref Tameable __instance)
		{
			return true;
		}
	}
	[HarmonyPatch(typeof(Tameable), "GetHoverName")]
	public static class Tameable_GetHoverName_Patch
	{
		public static void Postfix(ref Tameable __instance, ref string __result)
		{
		}
	}
	[HarmonyPriority(0)]
	[HarmonyPatch(typeof(Character), "ApplyDamage")]
	public static class Character_ApplyDamage_Patch
	{
		public static void Postfix(ref Character __instance, ref HitData hit, ref bool showDamageText, ref bool triggerEffects, ref DamageModifier mod)
		{
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static bool Prefix(Character __instance, long __0, HitData __1)
		{
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "UpdateWalking")]
	public static class MonsterAI_UpdateSleep_Patch
	{
		public static bool Prefix(Character __instance, ref float dt)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = WolfRecall.ToggleProtectionShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				WolfRecall.stunRecoveryTime = Time.unscaledTime + 5f;
			}
			if (Time.unscaledTime < WolfRecall.stunRecoveryTime && __instance.IsTamed())
			{
				MonsterAI component = ((Component)__instance).GetComponent<MonsterAI>();
				if (!((Object)(object)component == (Object)null))
				{
					Player localPlayer = Player.m_localPlayer;
					if (!((Object)(object)localPlayer == (Object)null) && (Object)(object)component.m_follow == (Object)(object)((Component)localPlayer).gameObject)
					{
						if (!((BaseAI)component).m_nview.IsOwner())
						{
							((BaseAI)component).m_nview.ClaimOwnership();
						}
						component.m_targetCreature = null;
						((BaseAI)component).SetAlerted(false);
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Tameable), "GetHoverText")]
	public static class Tameable_GetHoverText_Patch
	{
		public static void Postfix(Tameable __instance, ref string __result)
		{
		}
	}
}