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.Logging;
using EntityStates;
using EntityStates.TimedChest;
using On.EntityStates.TimedChest;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.Networking;
[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 = "")]
[assembly: AssemblyCompany("Timed_SeeS_Chest")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Timed_SeeS_Chest")]
[assembly: AssemblyTitle("Timed_SeeS_Chest")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace TimedSeeSChest;
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);
}
}
[BepInPlugin("Samuel17.Timed_SeeS_Chest", "Timed_SeeS_Chest", "1.0.1")]
public class Main : BaseUnityPlugin
{
public static string itemString = "EquipmentMagazine";
public static int itemCount = 5;
public void Awake()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
itemString = ((BaseUnityPlugin)this).Config.Bind<string>("Rewards", "Item Type", "EquipmentMagazine", "Specify the item dropped by the Timed Security Chest by entering its internal name.\nAlso accepts RandomWhite, RandomGreen and RandomRed as values.").Value;
itemCount = ((BaseUnityPlugin)this).Config.Bind<int>("Rewards", "Item Count", 5, "The amount of items dropped by the Timed Security Chest.").Value;
Opening.OnEnter += new hook_OnEnter(OpenChest);
}
private void OpenChest(orig_OnEnter orig, Opening self)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (!NetworkServer.active)
{
return;
}
Vector3 val = ((EntityState)self).transform.position + Vector3.up * 1.5f;
Vector3 val2 = Vector3.up * 24f + Vector3.forward * 4f;
float y = ((EntityState)self).transform.eulerAngles.y;
float num = itemCount switch
{
1 => 0f,
2 => -30f,
3 => -45f,
_ => -60f,
};
for (int i = 0; i < itemCount; i++)
{
PickupIndex val3 = ChooseItem();
if (val3 != PickupIndex.none)
{
Vector3 val4 = Quaternion.AngleAxis(y + num, Vector3.up) * val2;
PickupDropletController.CreatePickupDroplet(new UniquePickup(val3), val, val4, false, false);
num = itemCount switch
{
2 => num + 60f,
3 => num + 45f,
_ => num + (float)(120 / (itemCount - 1)),
};
}
}
}
private PickupIndex ChooseItem()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: 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_00d0: 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_00d3: Invalid comparison between Unknown and I4
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Expected I4, but got Unknown
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: 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_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
PickupIndex result = PickupIndex.none;
List<PickupIndex> list = null;
Xoroshiro128Plus treasureRng = Run.instance.treasureRng;
switch (itemString)
{
case "RandomWhite":
list = Run.instance.availableTier1DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case "RandomGreen":
list = Run.instance.availableTier2DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case "RandomRed":
list = Run.instance.availableTier3DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
default:
{
ItemIndex val = ItemCatalog.FindItemIndex(itemString);
if ((int)val == -1)
{
break;
}
ItemDef itemDef = ItemCatalog.GetItemDef(val);
if (!Object.op_Implicit((Object)(object)itemDef))
{
break;
}
ExpansionDef requiredExpansion = itemDef.requiredExpansion;
if (Object.op_Implicit((Object)(object)itemDef.requiredExpansion) && !Run.instance.IsExpansionEnabled(requiredExpansion))
{
ItemTier tier = itemDef.tier;
ItemTier val2 = tier;
switch ((int)val2)
{
case 0:
list = Run.instance.availableTier1DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 1:
list = Run.instance.availableTier2DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 2:
list = Run.instance.availableTier3DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 4:
list = Run.instance.availableBossDropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 3:
list = Run.instance.availableLunarItemDropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 6:
result = SwapToUncorruptedVariant(itemDef, list, treasureRng);
break;
case 7:
result = SwapToUncorruptedVariant(itemDef, list, treasureRng);
break;
case 8:
result = SwapToUncorruptedVariant(itemDef, list, treasureRng);
break;
case 9:
list = Run.instance.availableBossDropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
}
}
else
{
result = PickupCatalog.FindPickupIndex("ItemIndex." + itemString);
}
break;
}
}
return result;
}
private PickupIndex SwapToUncorruptedVariant(ItemDef itemDef, List<PickupIndex> list, Xoroshiro128Plus treasureRng)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_0028: 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_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: 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)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_00b5: Expected I4, but got Unknown
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: 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_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
PickupIndex result = PickupIndex.none;
Pair[] array = ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem];
Pair[] array2 = array;
foreach (Pair val in array2)
{
if (!((Object)(object)val.itemDef2 == (Object)(object)itemDef))
{
continue;
}
result = PickupCatalog.FindPickupIndex(val.itemDef1.itemIndex);
itemDef = val.itemDef1;
ExpansionDef requiredExpansion = itemDef.requiredExpansion;
if (!Object.op_Implicit((Object)(object)itemDef.requiredExpansion) || Run.instance.IsExpansionEnabled(requiredExpansion))
{
break;
}
ItemTier tier = itemDef.tier;
ItemTier val2 = tier;
switch ((int)val2)
{
case 0:
list = Run.instance.availableTier1DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 1:
list = Run.instance.availableTier2DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 2:
list = Run.instance.availableTier3DropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 4:
list = Run.instance.availableBossDropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
case 3:
list = Run.instance.availableLunarItemDropList;
if (list.Count > 0)
{
result = treasureRng.NextElementUniform<PickupIndex>(list);
}
break;
}
break;
}
return result;
}
}