using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RarityLib.Utils;
using UnboundLib.Cards;
using UnboundLib.GameModes;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: SecurityPermission(8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(/*Could not decode attribute arguments.*/)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ClassesManagerReborn.Patchs
{
[Serializable]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class RarityEnumValues : Object
{
private static void Postfix(Type enumType, ref Array __result)
{
if (enumType == typeof(Rarity))
{
__result = (Array)(object)Enumerable.ToArray<Rarity>(Enumerable.Select<Rarity, Rarity>((IEnumerable<Rarity>)(object)RarityUtils.rarities.Values, (Func<Rarity, Rarity>)((Rarity v) => v.value)));
}
}
}
[Serializable]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class RarityEnumCompair : Object
{
private static bool Prefix(Enum __instance, object target, ref int __result)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (__instance is Rarity rarity && target is Rarity rarity2)
{
float relativeRarity = RarityUtils.GetRarityData(rarity).relativeRarity;
float relativeRarity2 = RarityUtils.GetRarityData(rarity2).relativeRarity;
if (relativeRarity == relativeRarity2)
{
__result = 0;
}
else if (relativeRarity > relativeRarity2)
{
__result = -1;
}
else
{
__result = 1;
}
return false;
}
return true;
}
}
[Serializable]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class RarityEnumNames : Object
{
private static void Postfix(Type enumType, ref string[] __result)
{
if (enumType == typeof(Rarity))
{
__result = Enumerable.ToArray<string>(Enumerable.Select<Rarity, string>((IEnumerable<Rarity>)(object)RarityUtils.rarities.Values, (Func<Rarity, string>)((Rarity r) => r.name)));
}
}
}
[Serializable]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class RarityEnumToString : Object
{
private static void Postfix(Enum __instance, ref string __result)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
if (((Object)__instance).GetType() == typeof(Rarity))
{
try
{
__result = Enum.GetNames(typeof(Rarity))[(Rarity)(object)__instance];
}
catch (Object)
{
}
}
}
}
}
namespace RarityLib
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("root.rarity.lib", "Rarity Extention Library", "1.2.8")]
[BepInProcess("Rounds.exe")]
public class Main : BaseUnityPlugin
{
private const string ModId = "root.rarity.lib";
private const string ModName = "Rarity Extention Library";
public const string Version = "1.2.8";
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
new Harmony("root.rarity.lib").PatchAll();
RarityUtils.Started = true;
RarityUtils.AddRarity("Legendary", 0.025f, new Color(1f, 1f, 0f), new Color(0.7f, 0.7f, 0f));
}
private void Start()
{
RarityUtils.FinalizeRaritys();
GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)((IGameModeHandler gm) => RarityUtils.Reset()), 800);
RarityAdder[] array = (RarityAdder[])(object)Resources.FindObjectsOfTypeAll(typeof(RarityAdder));
foreach (RarityAdder rarityAdder in array)
{
if (((Behaviour)rarityAdder).enabled)
{
rarityAdder.SetUp();
}
}
}
}
public class testcard : CustomCard
{
public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
}
protected override GameObject GetCardArt()
{
return null;
}
protected override string GetDescription()
{
return "";
}
protected override Rarity GetRarity()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return RarityUtils.GetRarity("Legendary");
}
protected override CardInfoStat[] GetStats()
{
return (CardInfoStat[])(object)new CardInfoStat[0];
}
protected override CardThemeColorType GetTheme()
{
return (CardThemeColorType)3;
}
protected override string GetTitle()
{
return "RARITY TEST CARD";
}
}
}
namespace RarityLib.Utils
{
internal class RarityAdder : MonoBehaviour
{
public string rarityName = "Common";
internal void SetUp()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
((Component)this).GetComponent<CardInfo>().rarity = RarityUtils.GetRarity(rarityName);
}
}
public class RarityUtils : Object
{
[CompilerGenerated]
private sealed class <>c__DisplayClass11_0 : Object
{
public string rarityName;
public Rarity rarity;
internal bool <GetRarity>b__0(Rarity r)
{
return r.name == rarityName;
}
internal bool <GetRarity>b__1(int i)
{
return rarities[i] == rarity;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass9_0 : Object
{
public string name;
internal bool <AddRarity>b__0(Rarity r)
{
return r.name == name;
}
internal bool <AddRarity>b__1(int j)
{
return rarities[j].name == name;
}
}
internal static Dictionary<int, Rarity> rarities = new Dictionary<int, Rarity>();
internal static Dictionary<CardInfo, float> CardRarities = new Dictionary<CardInfo, float>();
internal static Dictionary<CardInfo, float> CardRaritiesAdd = new Dictionary<CardInfo, float>();
internal static Dictionary<CardInfo, float> CardRaritiesMul = new Dictionary<CardInfo, float>();
internal static List<Rarity> RarityList = new List<Rarity>();
internal static bool Finalized = false;
internal static bool Started = false;
public static IReadOnlyDictionary<int, Rarity> Rarities => (IReadOnlyDictionary<int, Rarity>)(object)rarities;
public static int AddRarity(string name, float relativeRarity, Color color, Color colorOff)
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
<>c__DisplayClass9_0 CS$<>8__locals0 = new <>c__DisplayClass9_0();
CS$<>8__locals0.name = name;
if (!Started)
{
throw new RarityException("The rarity registry hasnt been set up yet. \n Are you depending on raritylib?");
}
if (Finalized)
{
throw new RarityException("Rarities can no longer be registered. \n Is this being called in the mods awake function?");
}
int result = RarityList.Count + 3;
if (Enumerable.Any<Rarity>((IEnumerable<Rarity>)(object)rarities.Values, (Func<Rarity, bool>)((Rarity r) => r.name == CS$<>8__locals0.name)))
{
Debug.LogWarning((object)String.Concat("Rarity with name ", CS$<>8__locals0.name, " already exists"));
return Enumerable.First<int>(Enumerable.Where<int>((IEnumerable<int>)(object)rarities.Keys, (Func<int, bool>)((int j) => rarities[j].name == CS$<>8__locals0.name)));
}
if (relativeRarity <= 0f)
{
throw new RarityException("The relative rarity of a rarity must be greater than 0.");
}
RarityList.Add(new Rarity(CS$<>8__locals0.name, relativeRarity, color, colorOff, (Rarity)(-1)));
return result;
}
internal static void FinalizeRaritys()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_0076: 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)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
rarities.Add(0, new Rarity("Common", 1f, new Color(0.0978f, 0.1088f, 0.1321f), new Color(0.0978f, 0.1088f, 0.1321f), (Rarity)0));
rarities.Add(1, new Rarity("Uncommon", 0.4f, new Color(0.1745f, 0.6782f, 1f), new Color(0.1934f, 0.3915f, 0.5189f), (Rarity)1));
rarities.Add(2, new Rarity("Rare", 0.1f, new Color(1f, 0.1765f, 0.7567f), new Color(0.5283f, 0.1969f, 0.4321f), (Rarity)2));
RarityList.Sort((Comparison<Rarity>)((Rarity r1, Rarity r2) => ((Single)(ref r2.relativeRarity)).CompareTo(r1.relativeRarity)));
for (int i = 0; i < RarityList.Count; i++)
{
RarityList[i].value = (Rarity)(i + 3);
rarities.Add(3 + i, RarityList[i]);
}
Finalized = true;
}
public static Rarity GetRarity(string rarityName)
{
<>c__DisplayClass11_0 CS$<>8__locals0 = new <>c__DisplayClass11_0();
CS$<>8__locals0.rarityName = rarityName;
if (!Finalized)
{
throw new RarityException("Rarities cant be gotten before they have finished being registered. \n Are you waiting till at least the start function.");
}
CS$<>8__locals0.rarity = Enumerable.ToList<Rarity>((IEnumerable<Rarity>)(object)rarities.Values).Find((Predicate<Rarity>)((Rarity r) => r.name == CS$<>8__locals0.rarityName));
if (CS$<>8__locals0.rarity != null)
{
return (Rarity)Enumerable.ToList<int>((IEnumerable<int>)(object)rarities.Keys).Find((Predicate<int>)((int i) => rarities[i] == CS$<>8__locals0.rarity));
}
return (Rarity)0;
}
public static Rarity GetRarityData(Rarity rarity)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected I4, but got Unknown
return rarities[(int)rarity];
}
public static float GetCardRarityModifier(CardInfo card)
{
if (!CardRarities.ContainsKey(card))
{
CardRarities[card] = 1f;
}
if (!CardRaritiesAdd.ContainsKey(card))
{
CardRaritiesAdd[card] = 0f;
}
if (!CardRaritiesMul.ContainsKey(card))
{
CardRaritiesMul[card] = 1f;
}
return (CardRarities[card] + CardRaritiesAdd[card]) * CardRaritiesMul[card];
}
public static void SetCardRarityModifier(CardInfo card, float modifier)
{
Debug.Log((object)String.Format("Card {0}'s base rarity modifier set to {1}", (object)((Object)card).name, (object)modifier));
CardRarities[card] = modifier;
}
public static void AjustCardRarityModifier(CardInfo card, float add = 0f, float mul = 0f)
{
Debug.Log((object)String.Format("Card {0}'s rarity modifier ajusted by +{1} and *{2}", (object)((Object)card).name, (object)add, (object)mul));
if (!CardRaritiesAdd.ContainsKey(card))
{
CardRaritiesAdd[card] = 0f;
}
if (!CardRaritiesMul.ContainsKey(card))
{
CardRaritiesMul[card] = 1f;
}
Dictionary<CardInfo, float> cardRaritiesAdd = CardRaritiesAdd;
CardInfo val = card;
cardRaritiesAdd[val] += add;
cardRaritiesAdd = CardRaritiesMul;
val = card;
cardRaritiesAdd[val] += mul;
}
[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
internal static IEnumerator Reset()
{
CardRarities.Clear();
CardRaritiesAdd.Clear();
CardRaritiesMul.Clear();
Enumerable.ToList<Rarity>((IEnumerable<Rarity>)(object)rarities.Values).ForEach((Action<Rarity>)delegate(Rarity r)
{
r.calculatedRarity = r.relativeRarity;
});
yield break;
}
}
public class Rarity : Object
{
public string name;
public float relativeRarity;
public float calculatedRarity;
public Color color;
public Color colorOff;
public Rarity value;
internal Rarity(string name, float relativeRarity, Color color, Color colorOff, Rarity value)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
this.name = name;
this.relativeRarity = relativeRarity;
calculatedRarity = relativeRarity;
this.color = color;
this.colorOff = colorOff;
this.value = value;
}
public override bool Equals(object obj)
{
if (obj.GetType() == typeof(Rarity))
{
return ((Rarity)obj).name == name;
}
return false;
}
}
internal class RarityException : Exception
{
public RarityException(string message)
: base(message)
{
}
}
}
namespace RarityLib.Patches
{
[Serializable]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class CardChoicePatchGetRanomCard : Object
{
[HarmonyPriority(800)]
private static bool Prefix(CardInfo[] cards, ref GameObject __result)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected I4, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected I4, but got Unknown
float num = 0f;
for (int i = 0; i < cards.Length; i++)
{
num += RarityUtils.rarities[(int)cards[i].rarity].calculatedRarity * RarityUtils.GetCardRarityModifier(cards[i]);
}
float num2 = Random.Range(0f, num);
for (int j = 0; j < cards.Length; j++)
{
num2 -= RarityUtils.rarities[(int)cards[j].rarity].calculatedRarity * RarityUtils.GetCardRarityModifier(cards[j]);
if (num2 <= 0f)
{
__result = ((Component)cards[j]).gameObject;
break;
}
}
return false;
}
}
[Serializable]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class CardRarityColorPatchToggle : Object
{
private static bool Prefix(bool isOn, CardRarityColor __instance)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected I4, but got Unknown
//IL_0037: 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_0020: Expected I4, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
CardInfo componentInParent = ((Component)__instance).GetComponentInParent<CardInfo>();
((Graphic)((Component)__instance).GetComponent<Image>()).color = (isOn ? RarityUtils.rarities[(int)componentInParent.rarity].color : RarityUtils.rarities[(int)componentInParent.rarity].colorOff);
return false;
}
}
}