Decompiled source of ImprovedBoar v1.0.0

ValheimMod_ImprovedBoar.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ValheimMod_ImprovedBoar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimMod_ImprovedBoar")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f75a7681-7551-4776-bdf1-ea7dfc0a6e79")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ValheimMod;

[BepInPlugin("SkYMaN.ValheimMod_ImprovedBoar", "ImprovedBoar", "1.0.2")]
[BepInProcess("valheim.exe")]
public class Valheim_TeleportActivationDistanceClass : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Tameable), "Interact")]
	private class Patch_Boar
	{
		private static void Prefix()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			foreach (BaseAI allInstance in BaseAI.GetAllInstances())
			{
				if (((Object)allInstance).name == "Boar(Clone)")
				{
					allInstance.m_avoidFire = false;
					allInstance.m_afraidOfFire = configEntry_AfraidFireBoar.Value;
					Tameable component = ((Component)allInstance).GetComponent<Tameable>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.m_commandable = configEntry_CommandableBoar.Value;
						Character component2 = ((Component)allInstance).GetComponent<Character>();
						if (configEntry_MonsterFaction.Value)
						{
							component2.m_faction = (Faction)2;
						}
						else
						{
							component2.m_faction = (Faction)1;
						}
					}
				}
				else if (((Object)allInstance).name == "Boar_piggy(Clone)")
				{
					allInstance.m_avoidFire = false;
					allInstance.m_afraidOfFire = configEntry_AfraidFireBoar.Value;
				}
			}
		}
	}

	private readonly Harmony harmony = new Harmony("SkYMaN.ValheimMod_ImprovedBoar");

	private static ConfigEntry<bool> configEntry_CommandableBoar;

	private static ConfigEntry<bool> configEntry_AfraidFireBoar;

	private static ConfigEntry<bool> configEntry_MonsterFaction;

	private void Awake()
	{
		Debug.Log((object)"Starting loading mod - ImprovedBoar");
		harmony.PatchAll();
		configEntry_CommandableBoar = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Commandable Boar", false, "Commandable Boar");
		configEntry_AfraidFireBoar = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Boar Afraid Fire", true, "Boar Afraid Fire");
		configEntry_MonsterFaction = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Monster Faction Boar", false, "Monster Faction Boar");
		Debug.Log((object)"Finish loading mod - ImprovedBoar");
	}
}