using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("FollowDistance")]
[assembly: AssemblyTitle("FollowDistance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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.4")]
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.4";
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);
}
}
}