Decompiled source of WeaponSkillsSync v1.0.2

WeaponSkillsSync.dll

Decompiled 16 hours ago
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.Configuration;
using HarmonyLib;
using WeaponSkillsSync;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WeaponSkillsLevelTogether")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeaponSkillsLevelTogether")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("07cd1074-d4f3-4ba1-9f82-d9cf6f5159ab")]
[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")]
[HarmonyPatch(typeof(Skills), "RaiseSkill")]
public static class SkillPatch
{
	private static readonly FieldInfo skillDataField = AccessTools.Field(typeof(Skills), "m_skillData");

	private static bool isSyncing = false;

	private static readonly List<SkillType> combatSkills = new List<SkillType>
	{
		(SkillType)1,
		(SkillType)2,
		(SkillType)3,
		(SkillType)4,
		(SkillType)5,
		(SkillType)7,
		(SkillType)11,
		(SkillType)8,
		(SkillType)14,
		(SkillType)10,
		(SkillType)9
	};

	private static void Postfix(Skills __instance)
	{
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		combatSkills.Clear();
		if (SkillSyncConfig.SyncSwords.Value)
		{
			combatSkills.Add((SkillType)1);
		}
		if (SkillSyncConfig.SyncKnives.Value)
		{
			combatSkills.Add((SkillType)2);
		}
		if (SkillSyncConfig.SyncClubs.Value)
		{
			combatSkills.Add((SkillType)3);
		}
		if (SkillSyncConfig.SyncPolearms.Value)
		{
			combatSkills.Add((SkillType)4);
		}
		if (SkillSyncConfig.SyncSpears.Value)
		{
			combatSkills.Add((SkillType)5);
		}
		if (SkillSyncConfig.SyncAxes.Value)
		{
			combatSkills.Add((SkillType)7);
		}
		if (SkillSyncConfig.SyncUnarmed.Value)
		{
			combatSkills.Add((SkillType)11);
		}
		if (SkillSyncConfig.SyncBows.Value)
		{
			combatSkills.Add((SkillType)8);
		}
		if (SkillSyncConfig.SyncCrossbows.Value)
		{
			combatSkills.Add((SkillType)14);
		}
		if (SkillSyncConfig.SyncBloodMagic.Value)
		{
			combatSkills.Add((SkillType)10);
		}
		if (SkillSyncConfig.SyncElementalMagic.Value)
		{
			combatSkills.Add((SkillType)9);
		}
		if (isSyncing)
		{
			return;
		}
		isSyncing = true;
		try
		{
			Dictionary<SkillType, Skill> dictionary = (Dictionary<SkillType, Skill>)skillDataField.GetValue(__instance);
			float num = 0f;
			foreach (SkillType combatSkill in combatSkills)
			{
				if (dictionary.TryGetValue(combatSkill, out var value) && value.m_level > num)
				{
					num = value.m_level;
				}
			}
			SkillType[] array = combatSkills.ToArray();
			foreach (SkillType val in array)
			{
				if (dictionary.TryGetValue(val, out var value2) && value2.m_level < num)
				{
					float num2 = num - value2.m_level;
					value2.m_level = num;
					__instance.RaiseSkill(val, 0f);
				}
			}
		}
		finally
		{
			isSyncing = false;
		}
	}
}
namespace WeaponSkillsSync;

[BepInPlugin("com.gratalat.WeaponSkillsSync", "Weapon Skills Sync", "1.0.0")]
public class SkillSyncConfig : BaseUnityPlugin
{
	public static ConfigEntry<bool> SyncSwords;

	public static ConfigEntry<bool> SyncKnives;

	public static ConfigEntry<bool> SyncClubs;

	public static ConfigEntry<bool> SyncPolearms;

	public static ConfigEntry<bool> SyncSpears;

	public static ConfigEntry<bool> SyncAxes;

	public static ConfigEntry<bool> SyncBows;

	public static ConfigEntry<bool> SyncUnarmed;

	public static ConfigEntry<bool> SyncCrossbows;

	public static ConfigEntry<bool> SyncBloodMagic;

	public static ConfigEntry<bool> SyncElementalMagic;

	private void Awake()
	{
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Expected O, but got Unknown
		SyncSwords = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Swords", true, "Enable syncing Swords skill");
		SyncKnives = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Knives", true, "Enable syncing Knives skill");
		SyncClubs = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Clubs", true, "Enable syncing Clubs skill");
		SyncPolearms = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Polearms", true, "Enable syncing Polearms skill");
		SyncSpears = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Spears", true, "Enable syncing Spears skill");
		SyncAxes = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Axes", true, "Enable syncing Axes skill");
		SyncBows = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Bows", true, "Enable syncing Bows skill");
		SyncUnarmed = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Unarmed", true, "Enable syncing Unarmed skill");
		SyncCrossbows = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "Crossbows", true, "Enable syncing Crossbows skill");
		SyncBloodMagic = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "BloodMagic", true, "Enable syncing Blood Magic skill");
		SyncElementalMagic = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Skills", "ElementalMagic", true, "Enable syncing Elemental Magic skill");
		Harmony val = new Harmony("com.gratalat.WeaponSkillsSync");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Weapon Skills Sync loaded successfully.");
	}
}