using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LongstandingSolitudeFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+095700bfae3c9c4add6ad62882234325b5c8ed0d")]
[assembly: AssemblyProduct("LongstandingSolitudeFix")]
[assembly: AssemblyTitle("LongstandingSolitudeFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 LongstandingSolitudeFix
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Tutorials.ConfigurationTutorial", "ConfigurationTutorial", "1.0.0")]
public class Configs : BaseUnityPlugin
{
private static ConfigFile CustomConfigFile { get; set; }
public static ConfigEntry<bool> BreakIntoPearl { get; set; }
internal static void Init()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\LongstandingSolitudeFix.cfg", true);
BreakIntoPearl = CustomConfigFile.Bind<bool>("LongstandingSolitudeFix", "BreakIntoPearlAtMaxLevel", true, "Whether or not to break Longstanding Solitude into a pearl at max level");
}
}
public class Hooks
{
[CompilerGenerated]
private static class <>O
{
public static hook_SetState <0>__SceneExitController_SetState;
public static hook_OnBodyStart <1>__PlayerCharacterMasterController_OnBodyStart;
public static Action<CharacterBody> <2>__GlobalEventManager_onCharacterLevelUp;
public static hook_OnInteractionBegin <3>__PurchaseInteraction_OnInteractionBegin;
public static hook_GiveItem_ItemIndex_int <4>__Inventory_GiveItem_ItemIndex_int;
public static Action<Run> <5>__Run_onRunStartGlobal;
}
private static Dictionary<PlayerCharacterMasterController, int> playersLastBuffCount = new Dictionary<PlayerCharacterMasterController, int>();
internal static void Init()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
object obj = <>O.<0>__SceneExitController_SetState;
if (obj == null)
{
hook_SetState val = SceneExitController_SetState;
<>O.<0>__SceneExitController_SetState = val;
obj = (object)val;
}
SceneExitController.SetState += (hook_SetState)obj;
object obj2 = <>O.<1>__PlayerCharacterMasterController_OnBodyStart;
if (obj2 == null)
{
hook_OnBodyStart val2 = PlayerCharacterMasterController_OnBodyStart;
<>O.<1>__PlayerCharacterMasterController_OnBodyStart = val2;
obj2 = (object)val2;
}
PlayerCharacterMasterController.OnBodyStart += (hook_OnBodyStart)obj2;
GlobalEventManager.onCharacterLevelUp += GlobalEventManager_onCharacterLevelUp;
object obj3 = <>O.<3>__PurchaseInteraction_OnInteractionBegin;
if (obj3 == null)
{
hook_OnInteractionBegin val3 = PurchaseInteraction_OnInteractionBegin;
<>O.<3>__PurchaseInteraction_OnInteractionBegin = val3;
obj3 = (object)val3;
}
PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj3;
object obj4 = <>O.<4>__Inventory_GiveItem_ItemIndex_int;
if (obj4 == null)
{
hook_GiveItem_ItemIndex_int val4 = Inventory_GiveItem_ItemIndex_int;
<>O.<4>__Inventory_GiveItem_ItemIndex_int = val4;
obj4 = (object)val4;
}
Inventory.GiveItem_ItemIndex_int += (hook_GiveItem_ItemIndex_int)obj4;
Run.onRunStartGlobal += Run_onRunStartGlobal;
}
private static void Inventory_GiveItem_ItemIndex_int(orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
if (itemIndex != Items.OnLevelUpFreeUnlock.itemIndex)
{
orig.Invoke(self, itemIndex, count);
return;
}
if (!Configs.BreakIntoPearl.Value)
{
orig.Invoke(self, itemIndex, count);
return;
}
CharacterMaster component = ((Component)self).gameObject.GetComponent<CharacterMaster>();
if ((Object)(object)component == (Object)null)
{
orig.Invoke(self, itemIndex, count);
return;
}
CharacterBody body = component.GetBody();
if ((Object)(object)body == (Object)null)
{
orig.Invoke(self, itemIndex, count);
return;
}
if (body.level < (float)TeamManager.naturalLevelCap)
{
orig.Invoke(self, itemIndex, count);
return;
}
orig.Invoke(self, Items.Pearl.itemIndex, count);
CharacterMasterNotificationQueue.SendTransformNotification(body.master, Items.OnLevelUpFreeUnlock.itemIndex, Items.Pearl.itemIndex, (TransformationType)0);
}
private static void PurchaseInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
{
int num = 0;
CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
if ((Object)(object)component != (Object)null)
{
num = component.GetBuffCount(Buffs.FreeUnlocks);
}
orig.Invoke(self, activator);
if (num == 0 || (Object)(object)component == (Object)null || self.cost > 0)
{
return;
}
int buffCount = component.GetBuffCount(Buffs.FreeUnlocks);
if (num - buffCount > 0)
{
for (int i = 0; i < num - buffCount; i++)
{
component.AddBuff(Buffs.FreeUnlocks);
}
}
}
private static void ReplaceLSWithPearl(CharacterBody body, Inventory inventory)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
if (Configs.BreakIntoPearl.Value && !(body.level < (float)TeamManager.naturalLevelCap))
{
int itemCount = inventory.GetItemCount(Items.OnLevelUpFreeUnlock);
if (itemCount >= 1)
{
inventory.RemoveItem(Items.OnLevelUpFreeUnlock, itemCount);
inventory.GiveItem(Items.Pearl, itemCount);
CharacterMasterNotificationQueue.SendTransformNotification(body.master, Items.OnLevelUpFreeUnlock.itemIndex, Items.Pearl.itemIndex, (TransformationType)0);
}
}
}
private static void GlobalEventManager_onCharacterLevelUp(CharacterBody body)
{
ReplaceLSWithPearl(body, body.inventory);
}
private static void Run_onRunStartGlobal(Run obj)
{
playersLastBuffCount.Clear();
}
private static void PlayerCharacterMasterController_OnBodyStart(orig_OnBodyStart orig, PlayerCharacterMasterController self)
{
orig.Invoke(self);
if (!playersLastBuffCount.ContainsKey(self))
{
return;
}
CharacterBody body = self.master.GetBody();
if (!((Object)(object)body == (Object)null))
{
for (int i = 0; i < playersLastBuffCount[self]; i++)
{
body.AddBuff(Buffs.FreeUnlocks);
}
playersLastBuffCount.Remove(self);
}
}
private static void SceneExitController_SetState(orig_SetState orig, SceneExitController self, ExitState newState)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
if ((int)newState == 2)
{
foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
{
CharacterMaster master = instance.master;
if (!((Object)(object)master == (Object)null))
{
CharacterBody body = master.GetBody();
if (!((Object)(object)body == (Object)null))
{
int buffCount = body.GetBuffCount(Buffs.FreeUnlocks);
playersLastBuffCount[instance] = buffCount;
}
}
}
}
orig.Invoke(self, newState);
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("royal.LongstandingSolitudeFix", "LongstandingSolitudeFix", "1.0.0")]
public class Main : BaseUnityPlugin
{
public const string PluginGUID = "royal.LongstandingSolitudeFix";
public const string PluginAuthor = "royal";
public const string PluginName = "LongstandingSolitudeFix";
public const string PluginVersion = "1.0.0";
public void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
Configs.Init();
Hooks.Init();
}
}
}