using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Ash_ItemSpawn;
[BepInPlugin("Ashen_O.Ash_ItemSpawn", "Ash_ItemSpawn", "1.0.5")]
public class Ash_ItemSpawn : BaseUnityPlugin
{
private float spawnInterval = 0.01f;
private Dictionary<KeyCode, float> keyTimers = new Dictionary<KeyCode, float>();
public void Update()
{
HandleItemSpawn((KeyCode)282, (ItemTier)0);
HandleItemSpawn((KeyCode)283, (ItemTier)1);
HandleItemSpawn((KeyCode)284, (ItemTier)2);
HandleItemSpawn((KeyCode)285, (ItemTier)4);
HandleItemSpawn((KeyCode)286, (ItemTier)3);
}
private void HandleItemSpawn(KeyCode key, ItemTier tier)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (!Input.GetKey(key))
{
keyTimers[key] = 0f;
return;
}
float value = 0f;
keyTimers.TryGetValue(key, out value);
value -= Time.deltaTime;
if (value <= 0f)
{
SpawnItem(tier);
value = spawnInterval;
}
keyTimers[key] = value;
}
private void SpawnItem(ItemTier tier)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected I4, but got Unknown
LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
if ((Object)(object)val == (Object)null)
{
return;
}
ItemIndex[] array = ((IEnumerable<ItemIndex>)(object)ItemCatalog.allItems).Where((ItemIndex i) => ItemCatalog.GetItemDef(i).tier == tier).ToArray();
if (array.Length != 0)
{
int num = Random.Range(0, array.Length);
ItemIndex val2 = array[num];
ItemDef itemDef = ItemCatalog.GetItemDef(val2);
val.inventory.GiveItem(val2, 1);
string text = "Unknown";
ItemTier val3 = tier;
ItemTier val4 = val3;
switch ((int)val4)
{
case 0:
text = "White";
break;
case 1:
text = "Green";
break;
case 2:
text = "Red";
break;
case 4:
text = "Yellow";
break;
case 3:
text = "Lunar";
break;
}
Debug.Log((object)("[Ash][ItemSpawner] Spawned " + text + " item: " + itemDef.nameToken));
}
}
}