using System;
using System.CodeDom.Compiler;
using System.Configuration;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Mirror;
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("MultiTome")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MultiTome")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ed4e9a8f-7801-4745-aad3-584a7c1df45b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MultiTome
{
[BepInPlugin("rei.stonewards.multitome", "MultiTome", "0.1.8.0")]
public class MultiTome : BaseUnityPlugin
{
public const string pluginGuid = "rei.stonewards.multitome";
public const string pluginName = "MultiTome";
public const string pluginVersion = "0.1.8.0";
public static MultiTome Instance { get; private set; }
internal static ManualLogSource Log { get; private set; }
public static ConfigEntry<bool> SharePickupUpgrades { get; private set; }
public static ConfigEntry<bool> ShareRingUpgrades { get; private set; }
private void Awake()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"MultiTome 0.1.8.0 is starting...");
Harmony val = new Harmony("rei.stonewards.multitome");
SharePickupUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>("Sharing", "Share Pickup Upgrades", true, "When enabled, pickup upgrades are applied to all players.");
ShareRingUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>("Sharing", "Share Ring Upgrades", false, "When enabled, ring/level-up upgrades are applied to all players.");
try
{
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"MultiTome Harmony patches applied.");
foreach (MethodBase patchedMethod in val.GetPatchedMethods())
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Harmony patched: " + patchedMethod.DeclaringType?.FullName + "." + patchedMethod.Name));
}
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"Harmony patching failed: {arg}");
}
}
}
}
namespace MultiTome.Properties
{
[CompilerGenerated]
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "18.9.0.0")]
internal sealed class Settings : ApplicationSettingsBase
{
private static Settings defaultInstance = (Settings)(object)SettingsBase.Synchronized((SettingsBase)(object)new Settings());
public static Settings Default => defaultInstance;
}
}
namespace MultiTome.Patches
{
[HarmonyPatch(typeof(NetworkHelper), "UserCode_CmdApplyUpgrade__FirstPersonController__String__Rarity")]
public static class ApplyUpgradePatch
{
[HarmonyPrefix]
private static void Prefix(FirstPersonController _Player, string _UpgradeID, Rarity _UpgradeRarity)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
MultiTome.Log.LogInfo((object)("CmdApplyUpgrade: " + $"Player={_Player}, " + "UpgradeID=" + _UpgradeID + ", " + $"Rarity={_UpgradeRarity}"));
MultiTome.Log.LogInfo((object)$"Server connections: {NetworkServer.connections.Count}");
}
}
[HarmonyPatch(typeof(FirstPersonController), "UserCode_CmdPickupUpgrade__FirstPersonController__PickableItem")]
public static class PickupUpgradePatch
{
[HarmonyPrefix]
private static void Prefix(FirstPersonController _Owner, PickableItem _PickableItem)
{
MultiTome.Log.LogInfo((object)("CmdPickupUpgrade called. " + $"Owner={_Owner}, PickableItem={_PickableItem}"));
}
}
[HarmonyPatch(typeof(RogueLikeUpgradeManager), "ServerUpgradeAcquired")]
public static class ServerUpgradePatch
{
[HarmonyPostfix]
private static void Postfix(FirstPersonController _Player, RogueLikeUpgradeSO _Upgrade, Rarity _UpgradeRarity)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Invalid comparison between Unknown and I4
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active || (Object)(object)_Upgrade == (Object)null)
{
return;
}
bool flag = false;
UpgradeCategory upgradeCategory = _Upgrade.UpgradeCategory;
UpgradeCategory val = upgradeCategory;
if ((int)val != 0)
{
if ((int)val != 1)
{
return;
}
flag = MultiTome.SharePickupUpgrades.Value;
}
else
{
flag = MultiTome.ShareRingUpgrades.Value;
}
if (!flag)
{
return;
}
float bonusValuePerRarity = _Upgrade.GetBonusValuePerRarity(_UpgradeRarity);
MultiTome.Log.LogInfo((object)($"MultiTome: Sharing {_Upgrade.UpgradeCategory} " + ((BaseUpgradeSO)_Upgrade).ID + " with all players."));
foreach (NetworkConnectionToClient value in NetworkServer.connections.Values)
{
if (value == null || (Object)(object)((NetworkConnection)value).identity == (Object)null)
{
continue;
}
FirstPersonController component = ((Component)((NetworkConnection)value).identity).GetComponent<FirstPersonController>();
if (!((Object)(object)component == (Object)null) && !((Object)(object)component == (Object)(object)_Player))
{
_Upgrade.Effect.Apply(component, bonusValuePerRarity);
MultiTome.Log.LogInfo((object)("MultiTome: Applied " + ((BaseUpgradeSO)_Upgrade).ID + " to " + $"Player connId={value.connectionId}"));
if (!((NetworkBehaviour)component).isLocalPlayer)
{
NetworkHelper.Instance.TargetApplyUpgrade(value, component, ((BaseUpgradeSO)_Upgrade).ID, _UpgradeRarity);
MultiTome.Log.LogInfo((object)("MultiTome: Sent " + ((BaseUpgradeSO)_Upgrade).ID + " to " + $"client connId={value.connectionId}"));
}
}
}
}
}
}