using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using On.RoR2;
using PhilsBenthicPuritySwap.Items;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using VoidItemAPI;
[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("PhilsBenthicPuritySwap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PhilsBenthicPuritySwap")]
[assembly: AssemblyTitle("PhilsBenthicPuritySwap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PhilsBenthicPuritySwap
{
internal class Assets
{
public const string bundleName = "benthicpurityswap";
public static AssetBundle MainAssets { get; private set; }
public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(BenthicPuritySwap.PInfo.Location), "benthicpurityswap");
public static void Init()
{
MainAssets = AssetBundle.LoadFromFile(AssetBundlePath);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Boaphil.PhilsBenthicPuritySwap", "PhilsBenthicPuritySwap", "1.0.1")]
public class BenthicPuritySwap : BaseUnityPlugin
{
public const string PluginGUID = "Boaphil.PhilsBenthicPuritySwap";
public const string PluginAuthor = "Boaphil";
public const string PluginName = "PhilsBenthicPuritySwap";
public const string PluginVersion = "1.0.1";
public static PluginInfo PInfo { get; private set; }
public void Awake()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
PInfo = ((BaseUnityPlugin)this).Info;
Assets.Init();
ItemCatalog.Init += new hook_Init(OnItemCatalogInit);
LunarBenthic.Init();
VoidPurity.Init();
}
private void OnItemCatalogInit(orig_Init orig)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
ItemDef[] itemDefs = ContentManager.itemDefs;
foreach (ItemDef val in itemDefs)
{
if (((Object)val).name == "LunarBadLuck" || ((Object)val).name == "CloverVoid")
{
val._itemTierDef = null;
val.deprecatedTier = (ItemTier)5;
}
}
VoidTransformation.ModifyTransformation("CloverVoid", "Clover", (string)null, (ModificationType)1);
orig.Invoke();
}
}
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);
}
}
}
namespace PhilsBenthicPuritySwap.Items
{
internal class LunarBenthic
{
[CompilerGenerated]
private static class <>O
{
public static hook_OnServerStageBegin <0>__OnNextStage;
public static hook_OnInventoryChanged <1>__OnInventoryChanged;
}
public static ItemDef itemDef;
private static string itemName = "CloverLunar";
private static string upperName = itemName.ToUpper();
private static Xoroshiro128Plus cloverVoidRng;
public static Sprite LoadSprite()
{
return Assets.MainAssets.LoadAsset<Sprite>("assets/import/benthicpurityswap_icons/cloverLunar.png");
}
public static GameObject LoadPrefab()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/CloverVoid/PickupCloverVoid.prefab").WaitForCompletion();
}
public static ItemDef CreateItem()
{
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
((Object)val).name = itemName;
val.nameToken = "PHILSBENTHICPURITYSWAP_" + upperName + "_NAME";
val.pickupToken = "PHILSBENTHICPURITYSWAP_" + upperName + "_PICKUP";
val.descriptionToken = "PHILSBENTHICPURITYSWAP_" + upperName + "_DESC";
val.loreToken = "PHILSBENTHICPURITYSWAP_" + upperName + "_LORE";
val.tags = (ItemTag[])(object)new ItemTag[2]
{
(ItemTag)3,
(ItemTag)20
};
val.deprecatedTier = (ItemTier)3;
val.canRemove = true;
val.hidden = false;
val.pickupModelPrefab = LoadPrefab();
val.pickupIconSprite = LoadSprite();
return val;
}
public static ItemDisplayRuleDict CreateDisplayRules()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
return new ItemDisplayRuleDict((ItemDisplayRule[])null);
}
public static void AddHooks()
{
//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
object obj = <>O.<0>__OnNextStage;
if (obj == null)
{
hook_OnServerStageBegin val = OnNextStage;
<>O.<0>__OnNextStage = val;
obj = (object)val;
}
CharacterMaster.OnServerStageBegin += (hook_OnServerStageBegin)obj;
object obj2 = <>O.<1>__OnInventoryChanged;
if (obj2 == null)
{
hook_OnInventoryChanged val2 = OnInventoryChanged;
<>O.<1>__OnInventoryChanged = val2;
obj2 = (object)val2;
}
CharacterMaster.OnInventoryChanged += (hook_OnInventoryChanged)obj2;
}
private static void OnInventoryChanged(orig_OnInventoryChanged orig, CharacterMaster self)
{
orig.Invoke(self);
int itemCount;
if (Object.op_Implicit((Object)(object)self.inventory) && (itemCount = self.inventory.GetItemCount(itemDef)) > 0)
{
self.luck -= (float)itemCount;
}
}
private static void OnNextStage(orig_OnServerStageBegin orig, CharacterMaster self, Stage stage)
{
orig.Invoke(self, stage);
if (Object.op_Implicit((Object)(object)self.inventory) && self.inventory.GetItemCount(itemDef) > 0)
{
TryCloverUpgrades(self);
}
}
private static void TryCloverUpgrades(CharacterMaster characterMaster)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
Inventory inventory = characterMaster.inventory;
if (!NetworkServer.active)
{
return;
}
if (cloverVoidRng == null)
{
cloverVoidRng = new Xoroshiro128Plus(Run.instance.seed);
}
int itemCount = inventory.GetItemCount(itemDef);
List<PickupIndex> list = new List<PickupIndex>(Run.instance.availableTier2DropList);
List<PickupIndex> list2 = new List<PickupIndex>(Run.instance.availableTier3DropList);
List<ItemIndex> list3 = new List<ItemIndex>(inventory.itemAcquisitionOrder);
Util.ShuffleList<ItemIndex>(list3, cloverVoidRng);
int num = itemCount * 3;
int num2 = 0;
int num3 = 0;
while (num2 < num && num3 < list3.Count)
{
ItemDef startingItemDef = ItemCatalog.GetItemDef(list3[num3]);
ItemDef val = null;
List<PickupIndex> list4 = null;
ItemTier tier = startingItemDef.tier;
ItemTier val2 = tier;
if ((int)val2 != 0)
{
if ((int)val2 == 1)
{
list4 = list2;
}
}
else
{
list4 = list;
}
if (list4 != null && list4.Count > 0)
{
Util.ShuffleList<PickupIndex>(list4, cloverVoidRng);
list4.Sort(CompareTags);
PickupIndex val3 = list4[0];
val = ItemCatalog.GetItemDef(((PickupIndex)(ref val3)).itemIndex);
}
if ((Object)(object)val != (Object)null)
{
if (inventory.GetItemCount(val.itemIndex) == 0)
{
list3.Add(val.itemIndex);
}
num2++;
int itemCount2 = inventory.GetItemCount(startingItemDef.itemIndex);
inventory.RemoveItem(startingItemDef.itemIndex, itemCount2);
inventory.GiveItem(val.itemIndex, itemCount2);
CharacterMasterNotificationQueue.SendTransformNotification(characterMaster, startingItemDef.itemIndex, val.itemIndex, (TransformationType)2);
}
num3++;
int CompareTags(PickupIndex lhs, PickupIndex rhs)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
int num4 = 0;
int num5 = 0;
ItemDef val4 = ItemCatalog.GetItemDef(((PickupIndex)(ref lhs)).itemIndex);
ItemDef val5 = ItemCatalog.GetItemDef(((PickupIndex)(ref rhs)).itemIndex);
if (startingItemDef.ContainsTag((ItemTag)1))
{
if (val4.ContainsTag((ItemTag)1))
{
num4 = 1;
}
if (val5.ContainsTag((ItemTag)1))
{
num5 = 1;
}
}
if (startingItemDef.ContainsTag((ItemTag)2))
{
if (val4.ContainsTag((ItemTag)2))
{
num4 = 1;
}
if (val5.ContainsTag((ItemTag)2))
{
num5 = 1;
}
}
if (startingItemDef.ContainsTag((ItemTag)3))
{
if (val4.ContainsTag((ItemTag)3))
{
num4 = 1;
}
if (val5.ContainsTag((ItemTag)3))
{
num5 = 1;
}
}
return num5 - num4;
}
}
}
public static void Init()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
itemDef = CreateItem();
ItemAPI.Add(new CustomItem(itemDef, CreateDisplayRules()));
Log.Debug("Created " + itemName);
AddHooks();
}
}
internal class VoidPurity
{
[CompilerGenerated]
private static class <>O
{
public static StatHookEventHandler <0>__EditStats;
}
public static ItemDef itemDef;
private static string itemName = "VoidBadLuck";
private static string upperName = itemName.ToUpper();
public static Sprite LoadSprite()
{
return Assets.MainAssets.LoadAsset<Sprite>("assets/import/benthicpurityswap_icons/voidbadluck.png");
}
public static GameObject LoadPrefab()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/LunarBadLuck/PickupStarSeed.prefab").WaitForCompletion();
}
public static ItemDef CreateItem()
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
((Object)val).name = itemName;
val.nameToken = "PHILSBENTHICPURITYSWAP_" + upperName + "_NAME";
val.pickupToken = "PHILSBENTHICPURITYSWAP_" + upperName + "_PICKUP";
val.descriptionToken = "PHILSBENTHICPURITYSWAP_" + upperName + "_DESC";
val.loreToken = "PHILSBENTHICPURITYSWAP_" + upperName + "_LORE";
val.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)3 };
val.deprecatedTier = (ItemTier)8;
val.canRemove = true;
val.hidden = false;
val.pickupModelPrefab = LoadPrefab();
val.pickupIconSprite = LoadSprite();
return val;
}
public static ItemDisplayRuleDict CreateDisplayRules()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
return new ItemDisplayRuleDict((ItemDisplayRule[])null);
}
public static void AddHooks()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
VoidTransformation.CreateTransformation(itemDef, "Clover");
object obj = <>O.<0>__EditStats;
if (obj == null)
{
StatHookEventHandler val = EditStats;
<>O.<0>__EditStats = val;
obj = (object)val;
}
RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
}
private static void EditStats(CharacterBody sender, StatHookEventArgs args)
{
int itemCount;
if (Object.op_Implicit((Object)(object)sender.inventory) && (itemCount = sender.inventory.GetItemCount(itemDef)) > 0)
{
float cooldownReductionAdd = 2f + 1f * (float)(itemCount - 1);
args.cooldownReductionAdd = cooldownReductionAdd;
}
}
public static void Init()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
itemDef = CreateItem();
ItemAPI.Add(new CustomItem(itemDef, CreateDisplayRules()));
Log.Debug("Created " + itemName);
AddHooks();
}
}
}