using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using On.RoR2;
using R2API.Utils;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SharedLunarCoins")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+75623da37eb5d2c2d31c9c5775ae62ff000e021c")]
[assembly: AssemblyProduct("SharedLunarCoins")]
[assembly: AssemblyTitle("SharedLunarCoins")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SharedLunarCoins;
internal static class Hooks
{
public static void Init()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
LunarCoinDef.GrantPickup += new hook_GrantPickup(ShareLunarCoinsEvent);
}
private static void ShareLunarCoinsEvent(orig_GrantPickup orig, LunarCoinDef self, ref GrantContext context)
{
SharedLunarCoinsPlugin.Log.LogInfo((object)"Activated GrantPickup Event!");
NetworkUser val = Util.LookUpBodyNetworkUser(context.body);
SharedLunarCoinsPlugin.Log.LogInfo((object)("Player " + val.userName + " found a Lunar Coin."));
foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
{
if (Object.op_Implicit((Object)(object)Reflection.GetFieldValue<NetworkUser>((object)instance, "resolvedNetworkUserInstance")) && !((Object)(object)Reflection.GetFieldValue<NetworkUser>((object)instance, "resolvedNetworkUserInstance") == (Object)(object)val))
{
NetworkUser fieldValue = Reflection.GetFieldValue<NetworkUser>((object)instance, "resolvedNetworkUserInstance");
SharedLunarCoinsPlugin.Log.LogInfo((object)$"Awarding player {fieldValue.userName} a Lunar Coin! They started with: {val.lunarCoins}");
fieldValue.AwardLunarCoins(1u);
}
}
orig.Invoke(self, ref context);
}
}
[BepInPlugin("JasonMarco.SharedLunarCoins", "SharedLunarCoins", "1.0.1")]
public class SharedLunarCoinsPlugin : BaseUnityPlugin
{
private const string PluginAuthor = "JasonMarco";
private const string PluginName = "SharedLunarCoins";
private const string PluginVersion = "1.0.1";
private const string PluginGuid = "JasonMarco.SharedLunarCoins";
internal static ManualLogSource Log;
public void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Hooks.Init();
Log.LogMessage((object)"SharedLunarCoins Initialized.");
}
}