using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; 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.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("TameCommands")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TameCommands")] [assembly: AssemblyTitle("TameCommands")] [assembly: AssemblyVersion("1.0.0.0")] [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 TameCommands { [BepInPlugin("snowfarm.valheim.tamecommands", "TameCommands", "1.0.0")] public class TameCommandsPlugin : BaseUnityPlugin { public const string Guid = "snowfarm.valheim.tamecommands"; public const string Name = "TameCommands"; public const string Version = "1.0.0"; private static ManualLogSource _log; private static ConfigEntry _enabled; private static ConfigEntry _excludePrefabs; private static ConfigEntry _showHint; private static ConfigEntry _hintText; private static readonly HashSet Excluded = new HashSet(StringComparer.OrdinalIgnoreCase); private void Awake() { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) _log = ((BaseUnityPlugin)this).Logger; _enabled = ((BaseUnityPlugin)this).Config.Bind("1 - General", "Enabled", true, "Turn the plugin on or off."); _excludePrefabs = ((BaseUnityPlugin)this).Config.Bind("1 - General", "ExcludePrefabs", "", "Comma separated prefab names that keep vanilla behaviour (e.g. Hen,Chicken)."); _showHint = ((BaseUnityPlugin)this).Config.Bind("2 - Hover", "ShowHint", true, "Add a 'follow / stay' line to the hover text of tamed creatures."); _hintText = ((BaseUnityPlugin)this).Config.Bind("2 - Hover", "HintText", "[E] Follow / Stay", "Text used for the hover hint."); Excluded.Clear(); string[] array = (_excludePrefabs.Value ?? "").Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { Excluded.Add(text); } } new Harmony("snowfarm.valheim.tamecommands").PatchAll(typeof(TameCommandsPlugin)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"TameCommands 1.0.0 loaded."); } [HarmonyPostfix] [HarmonyPatch(typeof(Tameable), "Awake")] private static void TameableAwake(Tameable __instance) { if (_enabled.Value && !((Object)(object)__instance == (Object)null) && !Excluded.Contains(PrefabName(((Component)__instance).gameObject)) && !__instance.m_commandable) { __instance.m_commandable = true; _log.LogDebug((object)("'" + PrefabName(((Component)__instance).gameObject) + "' is now commandable.")); } } [HarmonyPostfix] [HarmonyPatch(typeof(Tameable), "GetHoverText")] private static void HoverPostfix(Tameable __instance, ref string __result) { if (_enabled.Value && _showHint.Value && !((Object)(object)__instance == (Object)null) && !string.IsNullOrEmpty(__result) && __instance.IsTamed() && __instance.m_commandable && !Excluded.Contains(PrefabName(((Component)__instance).gameObject))) { __result = __result + "\n" + _hintText.Value; } } private static string PrefabName(GameObject go) { if ((Object)(object)go == (Object)null) { return string.Empty; } string text = ((Object)go).name; int num = text.IndexOf("(Clone)", StringComparison.Ordinal); if (num >= 0) { text = text.Substring(0, num); } return text.Trim(); } } }