using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PerkShare")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PerkShare")]
[assembly: AssemblyTitle("PerkShare")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PerkShare
{
[BepInPlugin("com.liam.perkshare", "Perk Share", "1.0.0")]
public class PerkSharePlugin : BaseUnityPlugin
{
public const string PluginGuid = "com.liam.perkshare";
public const string PluginName = "Perk Share";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource Log;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("com.liam.perkshare").PatchAll();
Log.LogInfo((object)"Perk Share 1.0.0 loaded. Perks are now shared with the whole lobby.");
}
}
[HarmonyPatch(typeof(UpgradeManager), "ChangeUpgradeData")]
internal static class ShareUpgradePatch
{
private static bool _sharing;
private static void Postfix(UpgradeManager __instance, ulong steamId, PlayerUpgradeType type, float amount)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if (_sharing || !NetworkServer.active || amount == 0f)
{
return;
}
_sharing = true;
try
{
PlayerProfile[] array = Object.FindObjectsByType<PlayerProfile>((FindObjectsInactive)0, (FindObjectsSortMode)0);
foreach (PlayerProfile val in array)
{
if (!((Object)(object)val == (Object)null) && val.hasSynced && val.steamId != steamId)
{
__instance.ChangeUpgradeData(val.steamId, type, amount);
}
}
}
finally
{
_sharing = false;
}
}
}
}