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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SaneSkills")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimStats")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9b8fca2d-9424-4c21-9593-53e63ced4f59")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SaneSkills;
[BepInPlugin("com.Horpheus.valheim.SaneSkills", "SaneSkills", "1.1.1")]
public class SaneSkills : BaseUnityPlugin
{
internal static ManualLogSource Log;
private Harmony _harmony;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"SaneSkills loaded");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static class Skills_Constructor_Patch
{
public static void Postfix(Skills __instance)
{
__instance.m_totalSkillCap = 2000f;
}
}
public static class SkillGroups
{
private static readonly Dictionary<SkillType, SkillType[]> InitGroups;
private static readonly Dictionary<SkillType, float> InitMultipliers;
private static readonly SkillType[][] GroupLookup;
private static readonly float[] Multipliers;
private static readonly int MaxSkillIndex;
static SkillGroups()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Invalid comparison between Unknown and I4
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Expected I4, but got Unknown
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
InitGroups = new Dictionary<SkillType, SkillType[]>();
InitMultipliers = new Dictionary<SkillType, float>();
foreach (SkillType value in Enum.GetValues(typeof(SkillType)))
{
InitMultipliers[value] = 1f;
}
SkillType[] array = new SkillType[3];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
RegisterGroup((SkillType[])(object)array);
RegisterGroup((SkillType)3, (SkillType)11);
RegisterGroup((SkillType)4, (SkillType)5);
RegisterGroup((SkillType)13, (SkillType)12);
RegisterGroup((SkillType)8, (SkillType)14);
RegisterGroup((SkillType)9, (SkillType)10);
SkillType[] array2 = new SkillType[4];
RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
RegisterGroup((SkillType[])(object)array2);
SkillType[] array3 = new SkillType[4];
RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
RegisterGroup((SkillType[])(object)array3);
SetMultiplier((SkillType)100, 0.35f);
SetMultiplier((SkillType)101, 0.35f);
SetMultiplier((SkillType)103, 0.55f);
SetMultiplier((SkillType)102, 1.2f);
SetMultiplier((SkillType)4, 1.3f);
SetMultiplier((SkillType)14, 1.2f);
SetMultiplier((SkillType)3, 1.1f);
int num = 0;
foreach (SkillType value2 in Enum.GetValues(typeof(SkillType)))
{
if ((int)value2 > num)
{
num = (int)value2;
}
}
MaxSkillIndex = num + 1;
GroupLookup = new SkillType[MaxSkillIndex][];
Multipliers = new float[MaxSkillIndex];
foreach (KeyValuePair<SkillType, SkillType[]> initGroup in InitGroups)
{
GroupLookup[initGroup.Key] = initGroup.Value;
}
foreach (KeyValuePair<SkillType, float> initMultiplier in InitMultipliers)
{
Multipliers[initMultiplier.Key] = initMultiplier.Value;
}
}
private static void RegisterGroup(params SkillType[] skills)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected I4, but got Unknown
foreach (SkillType val in skills)
{
SkillType[] array = (SkillType[])(object)new SkillType[skills.Length - 1];
int num = 0;
foreach (SkillType val2 in skills)
{
if (val2 != val)
{
array[num++] = (SkillType)(int)val2;
}
}
InitGroups[val] = array;
}
}
private static void SetMultiplier(SkillType skill, float value)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
InitMultipliers[skill] = value;
}
public static SkillType[] GetOtherSkills(SkillType skill)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Expected I4, but got Unknown
int num = (int)skill;
return (num >= 0 && num < MaxSkillIndex && GroupLookup[num] != null) ? GroupLookup[num] : Array.Empty<SkillType>();
}
public static float GetMultiplier(SkillType skill)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Expected I4, but got Unknown
int num = (int)skill;
return (num >= 0 && num < MaxSkillIndex) ? Multipliers[num] : 1f;
}
}
[HarmonyPatch(typeof(Skills), "RaiseSkill")]
public static class RaiseSkill_Patch
{
private static bool _isRaisingExtraSkills;
public static void Postfix(Skills __instance, SkillType skillType, float factor)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if (_isRaisingExtraSkills || (int)skillType == 0 || factor <= 0f)
{
return;
}
SkillType[] otherSkills = SkillGroups.GetOtherSkills(skillType);
if (otherSkills.Length == 0)
{
return;
}
try
{
_isRaisingExtraSkills = true;
foreach (SkillType val in otherSkills)
{
__instance.RaiseSkill(val, SkillGroups.GetMultiplier(val));
}
}
finally
{
_isRaisingExtraSkills = false;
}
}
}