using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("GooderAquaticArsenal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Main Street Gaming")]
[assembly: AssemblyProduct("GooderEquipInWater")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
namespace GooderAquaticArsenal;
[BepInPlugin("MainStreetGaming.GooderAquaticArsenal", "GooderAquaticArsenal", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInIncompatibility("com.lvh-it.valheim.useequipmentinwater")]
internal class GooderAquaticArsenal : BaseUnityPlugin
{
public const string PluginGUID = "MainStreetGaming.GooderAquaticArsenal";
public const string PluginName = "GooderAquaticArsenal";
public const string PluginVersion = "1.0.1";
public static ConfigEntry<bool> _enableDebug;
public static ConfigEntry<bool> AllowAxe;
public static ConfigEntry<bool> AllowBattleAxe;
public static ConfigEntry<bool> AllowSword;
public static ConfigEntry<bool> AllowBow;
public static ConfigEntry<bool> AllowCrossbow;
public static ConfigEntry<bool> AllowAtgeir;
public static ConfigEntry<bool> AllowKnife;
public static ConfigEntry<bool> AllowMace;
public static ConfigEntry<bool> AllowSledge;
public static ConfigEntry<bool> AllowSpear;
public static ConfigEntry<bool> AllowClub;
public static ConfigEntry<bool> AllowTorch;
public static ConfigEntry<bool> AllowPickaxe;
public static ConfigEntry<bool> AllowCultivator;
public static ConfigEntry<bool> AllowFishingrod;
public static ConfigEntry<bool> AllowHammer;
public static ConfigEntry<bool> AllowHoe;
public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();
private void Awake()
{
string[] array = new string[10] { "Attention players: The chaos committee has approved {0} for immediate deployment!", "And here we have {0}, the plugin that makes all other plugins jealous.", "Prepare for a wild ride! {0} just slipped through the cracks and landed in our game.", "And just like that, the game became 100% more interesting. Thank you, {0}!", "Attention gamers: {0} has arrived fashionably late to the party, and it brought confetti cannons.", "Hold onto your keyboards! {0} just crashed the game... figuratively, of course.", "And just like that, the game went from 'meh' to 'oh heck yeah!' Thanks, {0}!", "Rumor has it that {0} is the secret ingredient in the developer's coffee.", "We're not saying {0} is the hero this game deserves... but it's the one it's stuck with.", "Don't worry, it's just {0}. The flames are purely cosmetic... probably." };
int num = new Random().Next(array.Length);
Logger.LogInfo((object)string.Format(array[num], "GooderAquaticArsenal"));
CreateConfigValues();
Harmony.CreateAndPatchAll(typeof(GooderAquaticArsenal), (string)null);
}
private void CreateConfigValues()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Expected O, but got Unknown
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Expected O, but got Unknown
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Expected O, but got Unknown
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Expected O, but got Unknown
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Expected O, but got Unknown
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Expected O, but got Unknown
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Expected O, but got Unknown
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Expected O, but got Unknown
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Expected O, but got Unknown
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Expected O, but got Unknown
ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
{
IsAdminOnly = true
};
_enableDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugMode", false, "Enable debug logging.");
AllowAxe = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowAxe", true, new ConfigDescription("Allow axes while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowBattleAxe = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowBattleAxe", true, new ConfigDescription("Allow Battle Axes while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowSword = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowSword", true, new ConfigDescription("Allow swords while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowBow = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowBow", true, new ConfigDescription("Allow bows while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowCrossbow = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowCrossbow", true, new ConfigDescription("Allow crossbows while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowAtgeir = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowAtgeir", true, new ConfigDescription("Allow Atgeirs while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowKnife = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowKnife", true, new ConfigDescription("Allow Knives while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowMace = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowMace", true, new ConfigDescription("Allow Maces while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowSledge = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowSledge", true, new ConfigDescription("Allow Sledges while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowSpear = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowSpear", true, new ConfigDescription("Allow Spears while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowClub = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowClub", true, new ConfigDescription("Allow Clubs while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowTorch = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowTorch", true, new ConfigDescription("Allow Torches while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowPickaxe = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowPickaxe", true, new ConfigDescription("Allow Pickaxes while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowCultivator = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowCultivator", true, new ConfigDescription("Allow Cultivators while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowFishingrod = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowFishingrod", true, new ConfigDescription("Allow Fishingrods while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowHammer = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowHammer", true, new ConfigDescription("Allow Hammers while swimming", (AcceptableValueBase)null, new object[1] { val }));
AllowHoe = ((BaseUnityPlugin)this).Config.Bind<bool>("Server config", "AllowHoe", true, new ConfigDescription("Allow Hoes while swimming", (AcceptableValueBase)null, new object[1] { val }));
}
public static void DebugLog(string data)
{
if (_enableDebug.Value)
{
Logger.LogInfo((object)("GooderAquaticArsenal: " + data));
}
}
[HarmonyPatch(typeof(Character), "IsSwimming")]
[HarmonyPrefix]
private static bool OverrideIsSwimming(ref bool __result, Character __instance, float ___m_swimTimer)
{
if (___m_swimTimer >= 0.5f)
{
return true;
}
StackTrace stackTrace = new StackTrace();
string text = "";
for (int i = 2; i < stackTrace.FrameCount && i < 10; i++)
{
text = text + stackTrace.GetFrame(i).GetMethod().Name + "-";
}
Humanoid val = (Humanoid)(object)((__instance is Humanoid) ? __instance : null);
if (val != null && ((Character)val).IsPlayer())
{
ItemData rightItem = val.GetRightItem();
ItemData leftItem = val.GetLeftItem();
DebugLog("RighthandItem: " + (object)rightItem);
if (rightItem != null && ItemNotAllowed(rightItem))
{
DebugLog("Right hand item not allowed: " + rightItem.m_shared.m_name);
val.UnequipItem(rightItem, false);
}
DebugLog("LefthandItem: " + (object)leftItem);
if (leftItem != null && ItemNotAllowed(leftItem))
{
DebugLog("Left hand item not allowed: " + leftItem.m_shared.m_name);
val.UnequipItem(leftItem, false);
}
}
if (__instance.IsPlayer() && (text.Contains("UpdateEquipment") || text.Contains("EquipItem")))
{
__result = false;
return false;
}
return true;
}
[HarmonyPatch(typeof(Humanoid), "EquipItem")]
[HarmonyPrefix]
private static void PatchEquipItem()
{
}
private static bool ItemNotAllowed(ItemData item)
{
foreach (KeyValuePair<string, ConfigEntry<bool>> item2 in new Dictionary<string, ConfigEntry<bool>>
{
{ "_axe_", AllowAxe },
{ "battleaxe", AllowBattleAxe },
{ "sword", AllowSword },
{ "_bow", AllowBow },
{ "_crossbow_", AllowCrossbow },
{ "atgeir", AllowAtgeir },
{ "knife", AllowKnife },
{ "mace", AllowMace },
{ "sledge", AllowSledge },
{ "spear", AllowSpear },
{ "club", AllowClub },
{ "torch", AllowTorch },
{ "pickaxe", AllowPickaxe },
{ "cultivator", AllowCultivator },
{ "fishingrod", AllowFishingrod },
{ "hammer", AllowHammer },
{ "hoe", AllowHoe }
})
{
if (item.m_shared.m_name.Contains(item2.Key) && !item2.Value.Value)
{
return true;
}
}
return false;
}
}