using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 On.RoR2.ExpansionManagement;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
[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("CorruptibleChanceDolls")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CorruptibleChanceDolls")]
[assembly: AssemblyTitle("CorruptibleChanceDolls")]
[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 CorruptibleChanceDolls
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("CryoBlind.CorruptibleChanceDolls", "CorruptibleChanceDolls", "1.0.3")]
public class CorruptibleChanceDolls : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_OnInteractionBegin <0>__PurchaseInteraction_OnInteractionBegin;
}
public const string PluginGUID = "CryoBlind.CorruptibleChanceDolls";
public const string PluginAuthor = "CryoBlind";
public const string PluginName = "CorruptibleChanceDolls";
public const string PluginVersion = "1.0.3";
private static ItemDef CorruptedChanceDoll;
private static GameObject chanceSuccessEffect;
private static ConfigFile CorruptedChanceDollsConfig { get; set; }
public static ConfigEntry<float> ExtraItemBaseChance { get; set; }
public static ConfigEntry<float> ExtraItemStackScale { get; set; }
public static ConfigEntry<float> ExtraItemMaxChance { get; set; }
public static PluginInfo PInfo { get; private set; }
public void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Expected O, but got Unknown
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Expected O, but got Unknown
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Expected O, but got Unknown
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Expected O, but got Unknown
CorruptedChanceDollsConfig = new ConfigFile(Paths.ConfigPath + "\\CorruptibleChanceDolls.cfg", true);
ExtraItemBaseChance = CorruptedChanceDollsConfig.Bind<float>("Base Chance For Extra Item", "ExtraItemBaseChance", 15f, "This is how likely the corrupted chance doll is to proc with a stack of only 1 in the player's inventory");
ExtraItemStackScale = CorruptedChanceDollsConfig.Bind<float>("Scaling Factor", "ExtraItemStackScale", 0.5f, "Dictates how fast the item scales with additional stacks");
ExtraItemMaxChance = CorruptedChanceDollsConfig.Bind<float>("Maximum Chance For Extra Item", "ExtraItemMaxChance", 80f, "The chance of getting an extra item is clamped below this value");
PInfo = ((BaseUnityPlugin)this).Info;
Log.Init(((BaseUnityPlugin)this).Logger);
Asset.Init();
CorruptedChanceDoll = ScriptableObject.CreateInstance<ItemDef>();
((Object)CorruptedChanceDoll).name = "CORRUPTED_CHANCE_DOLL";
CorruptedChanceDoll.nameToken = "Chance Effigy";
CorruptedChanceDoll.pickupToken = "The power of voodoo, who do, you do";
CorruptedChanceDoll.descriptionToken = "Chance for an Chance Shrine drop to not be counted towards the total drops from that chance shrine. Scales according to: % chance = " + ExtraItemBaseChance.Value + " + " + ExtraItemBaseChance.Value + "(x-1)^" + ExtraItemStackScale.Value + " for x >= 1 up to " + ExtraItemMaxChance.Value + "% chance";
CorruptedChanceDoll.loreToken = "Chance for an Chance Shrine drop to not be counted towards the total drops from that chance shrine. Scales according to: % chance = " + ExtraItemBaseChance.Value + " + " + ExtraItemBaseChance.Value + "(x-1)^" + ExtraItemStackScale.Value + " for x >= 1 up to " + ExtraItemMaxChance.Value + "% chance";
CorruptedChanceDoll._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/DLC1/Common/VoidTier2Def.asset").WaitForCompletion();
CorruptedChanceDoll.pickupIconSprite = Asset.mainBundle.LoadAsset<Sprite>("texCorruptedChanceDollIco.png");
CorruptedChanceDoll.pickupModelPrefab = Asset.mainBundle.LoadAsset<GameObject>("PickupCorruptedChanceDoll.prefab");
CorruptedChanceDoll.canRemove = true;
CorruptedChanceDoll.hidden = false;
ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
new ContentPack();
ItemDef itemDef = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/DLC2/Items/ExtraShrineItem/ExtraShrineItem.asset").WaitForCompletion();
ItemRelationshipProvider val2 = ScriptableObject.CreateInstance<ItemRelationshipProvider>();
((Object)val2).name = "CorruptedChanceDollRelationshipProvider";
val2.relationshipType = Addressables.LoadAssetAsync<ItemRelationshipType>((object)"RoR2/DLC1/Common/ContagiousItem.asset").WaitForCompletion();
val2.relationships = (Pair[])(object)new Pair[1]
{
new Pair
{
itemDef1 = itemDef,
itemDef2 = CorruptedChanceDoll
}
};
ItemAPI.Add(new CustomItem(CorruptedChanceDoll, val));
ContentAddition.AddItemRelationshipProvider(val2);
chanceSuccessEffect = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/VoidChest/VoidChestPurchaseEffect.prefab").WaitForCompletion();
object obj = <>O.<0>__PurchaseInteraction_OnInteractionBegin;
if (obj == null)
{
hook_OnInteractionBegin val3 = PurchaseInteraction_OnInteractionBegin;
<>O.<0>__PurchaseInteraction_OnInteractionBegin = val3;
obj = (object)val3;
}
PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj;
ExpansionCatalog.Init += new hook_Init(ExpansionCatalog_Init);
}
private void ExpansionCatalog_Init(orig_Init orig)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke();
CorruptedChanceDoll.requiredExpansion = ((IEnumerable<ExpansionDef>)(object)ExpansionCatalog.expansionDefs).Where((ExpansionDef expansionDef) => expansionDef.nameToken == "DLC1_NAME").FirstOrDefault();
}
private static void PurchaseInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
ShrineChanceBehavior component = ((Component)self).gameObject.GetComponent<ShrineChanceBehavior>();
if ((Object)(object)component != (Object)null)
{
CharacterBody component2 = ((Component)activator).gameObject.GetComponent<CharacterBody>();
int successfulPurchaseCount = component.successfulPurchaseCount;
orig.Invoke(self, activator);
if (successfulPurchaseCount < component.successfulPurchaseCount)
{
int itemCount = component2.inventory.GetItemCount(CorruptedChanceDoll.itemIndex);
if (itemCount > 0 && Util.CheckRoll(Mathf.Clamp(ExtraItemBaseChance.Value + ExtraItemBaseChance.Value * Mathf.Pow((float)(itemCount - 1), ExtraItemStackScale.Value), 0f, ExtraItemMaxChance.Value), component2.master))
{
component.successfulPurchaseCount--;
EffectManager.SpawnEffect(chanceSuccessEffect, new EffectData
{
origin = ((Component)self).gameObject.transform.position + new Vector3(0f, 2.5f, 0f),
rotation = Quaternion.identity,
scale = 2.5f
}, true);
}
}
}
else
{
orig.Invoke(self, activator);
}
}
}
public static class Asset
{
public static AssetBundle mainBundle;
public const string bundleName = "corruptiblechancedollassets";
public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(CorruptibleChanceDolls.PInfo.Location), "corruptiblechancedollassets");
public static void Init()
{
mainBundle = AssetBundle.LoadFromFile(AssetBundlePath);
}
}
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);
}
}
}