using System.Diagnostics;
using System.Reflection;
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 BepInEx.Logging;
using HarmonyLib;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BeehiveUtilities")]
[assembly: AssemblyDescription("Valheim, Beehive, Remove the Proximity and Biome Check")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BeehiveUtilities")]
[assembly: AssemblyCopyright("Copyright © by mennowar 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f070453f-a62d-4fa2-8bab-64b29bfa0ead")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
namespace BeehiveUtilities;
[BepInPlugin("mennowar.mods.beehiveutilities_revived", "Beehive Utilities Revived", "1.0.2")]
[BepInDependency("com.jotunn.jotunn", "2.23.2")]
[HarmonyPatch]
internal class BeehiveUtilitiesPlugin : BaseUnityPlugin
{
private static ConfigEntry<bool> enableMod;
private static ConfigEntry<bool> disableDistanceCheck;
private static ConfigEntry<bool> removeBiomeCheck;
private static ConfigEntry<bool> honeySpawnInFront;
private static ConfigEntry<int> maxHoney;
private static ConfigEntry<double> minsCreation;
private static int creationTimeInSeconds;
private static ConfigEntry<bool> writeDebugOutput;
private static ManualLogSource log;
public static void Debug(string value)
{
if (writeDebugOutput.Value)
{
if (log == null)
{
log = Logger.CreateLogSource("Beehive UR");
}
if (log != null)
{
log.LogMessage((object)value);
}
}
}
private static void WriteInfo()
{
Debug($"Disable Proximity Check: {disableDistanceCheck.Value}");
Debug($"Max Honey: {maxHoney.Value}");
Debug($"Minutes Per Creation: {minsCreation.Value}");
Debug($"Remove Biome Check: {removeBiomeCheck.Value}");
Debug($"Spawn Honey In Front: {honeySpawnInFront.Value}");
}
private void Awake()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Expected O, but got Unknown
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Expected O, but got Unknown
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Expected O, but got Unknown
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Expected O, but got Unknown
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Global", "Enable Mod", true, new ConfigDescription("Is this mod enabled?", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
if (enableMod.Value)
{
writeDebugOutput = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Global", "Enable Debug", false, new ConfigDescription("Write additional Debug Output", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
disableDistanceCheck = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - General", "Disable Proximity Check", true, new ConfigDescription("Disable the \"Bees need more space\" check", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
maxHoney = ((BaseUnityPlugin)this).Config.Bind<int>("2 - General", "Max Honey", 10, new ConfigDescription("The maximum amount of honey a beehive can generate (game default is 10)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
minsCreation = ((BaseUnityPlugin)this).Config.Bind<double>("2 - General", "Minutes Per Creation", 20.0, new ConfigDescription("The amount of minutes it takes to generate 1 piece of honey (default is 20)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
removeBiomeCheck = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - General", "Remove Biome Check", true, new ConfigDescription("Allow the beehives to work in any Biome", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
honeySpawnInFront = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - General", "Spawn Honey In Front", true, new ConfigDescription("Spawns the honey in front of the hive instead of on top of it. Here is a picture to show which way is the front of the hive, it's the side where the thatch overlaps from the sides on top.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
{
IsAdminOnly = true
} }));
WriteInfo();
creationTimeInSeconds = (int)(minsCreation.Value * 60.0);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
SynchronizationManager.OnConfigurationSynchronized += SynchronizationManager_OnConfigurationSynchronized;
}
}
private void SynchronizationManager_OnConfigurationSynchronized(object sender, ConfigurationSynchronizationEventArgs e)
{
creationTimeInSeconds = (int)(minsCreation.Value * 60.0);
Debug(e.InitialSynchronization ? "Getting Initial Config" : "Config has been updated");
}
private static void SetBeeStats(Beehive __instance)
{
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
if (enableMod.Value)
{
Debug("-------- Setting BeeHive Status ----------");
bool flag = !EnvMan.IsNight();
__instance.m_beeEffect.SetActive(flag);
Debug($"Bee-Effect isActive: {flag}");
__instance.m_secPerUnit = creationTimeInSeconds;
__instance.m_maxHoney = maxHoney.Value;
Debug($"Seconds per Unit: {__instance.m_secPerUnit}");
Debug($"Max Honey: {__instance.m_maxHoney}");
if (honeySpawnInFront.Value)
{
__instance.m_spawnPoint.localPosition = new Vector3(0.8f, 0f, 0f);
Debug("Honey should spawn in front");
}
else
{
Debug("Honey spawns at default position");
}
if (disableDistanceCheck.Value)
{
__instance.m_maxCover = 1000f;
Debug($"Max Distance: {__instance.m_maxCover}");
}
else
{
Debug("Proximity check disabled");
}
if (removeBiomeCheck.Value)
{
__instance.m_biome = (Biome)639;
Debug($"Biome set to everywhere: {__instance.m_biome}");
}
else
{
Debug("Biome-Check disabled");
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Beehive), "UpdateBees")]
public static void BeehiveUpdateBees_Patch(Beehive __instance)
{
SetBeeStats(__instance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Beehive), "Awake")]
public static void BeehiveAwake_Patch(Beehive __instance)
{
SetBeeStats(__instance);
}
}