using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FollowDistance")]
[assembly: AssemblyDescription("https://valheim.thunderstore.io/package/blacks7ar/FollowDistance/")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyProduct("FollowDistance")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("BA359044-5757-4046-95EE-0F036AB44726")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 FollowDistance
{
[BepInPlugin("blacks7ar.FollowDistance", "FollowDistance", "1.0.3")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch]
public static class Patches
{
[HarmonyTranspiler]
[HarmonyPatch(typeof(BaseAI), "Follow")]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
foreach (CodeInstruction instruction in instructions)
{
if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)3f))
{
instruction.operand = _distance.Value;
}
}
return instructions;
}
}
private const string modGUID = "blacks7ar.FollowDistance";
public const string modName = "FollowDistance";
public const string modAuthor = "blacks7ar";
public const string modVersion = "1.0.3";
public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/FollowDistance/";
private static readonly Harmony _harmony = new Harmony("blacks7ar.FollowDistance");
private static ConfigEntry<float> _distance;
public void Awake()
{
((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
_distance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Distance", 9f, "Players distance before your tames follows you.\nNeeds a Restart to take effect.");
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
((BaseUnityPlugin)this).Config.Save();
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
}
}
}